From 508ac0aa7987f96a33de0ad5a235c1e058d924cb Mon Sep 17 00:00:00 2001 From: "Graciliano M. P." Date: Tue, 1 Sep 2026 22:09:24 -0300 Subject: [PATCH 1/2] fix: resolve an `enum` route parameter from a qualified name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A route parameter typed as an `enum` threw when the value arrived as `Currency.brl` — the form `Enum.toString()` produces, and the one external callers tend to send: type 'String' is not a subtype of type 'Currency?' of 'chargedCurrency' `EnumReflection.from` only read a bare value name, so the qualified form parsed to `null`, `APIRouteBuilder.resolveValueByType` fell back to the value it was given, and the raw `String` reached `Function.apply`. Fixed upstream in `reflection_factory: ^2.10.0`. Adds `bones_api_route_enum_parameter_test.dart`, covering the qualified name alongside the bare name, a case-insensitive name, a JSON payload and a null `enum` parameter. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01RVuPYBSbnLEWVqPXTcmZU2 --- CHANGELOG.md | 17 + lib/src/bones_api_base.dart | 2 +- pubspec.yaml | 4 +- test/bones_api_route_enum_parameter_test.dart | 222 +++ ...oute_enum_parameter_test.reflection.g.dart | 1277 +++++++++++++++++ test/bones_api_test.reflection.g.dart | 4 +- .../bones_api_test_entities.reflection.g.dart | 4 +- ...api_test_entities_orders.reflection.g.dart | 4 +- test/bones_api_test_modules.reflection.g.dart | 4 +- ...ones_api_test_utils_test.reflection.g.dart | 4 +- 10 files changed, 1529 insertions(+), 13 deletions(-) create mode 100644 test/bones_api_route_enum_parameter_test.dart create mode 100644 test/bones_api_route_enum_parameter_test.reflection.g.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 43ce12d..1ab927a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +## 1.16.1 + +- A route parameter typed as an `enum` no longer fails when the value arrives as + a qualified name (`Currency.brl`), the form an `enum.toString()` produces and + the one external callers tend to send: + + ``` + type 'String' is not a subtype of type 'Currency?' of 'chargedCurrency' + ``` + + `EnumReflection.from` only read a bare value name, so the qualified form + parsed to `null`, `APIRouteBuilder.resolveValueByType` fell back to the value + it was given, and the raw `String` reached `Function.apply`. The bare name + (`brl`), in any case, already resolved. + +- deps: `reflection_factory: ^2.10.0`, which resolves the qualified `enum` name. + ## 1.16.0 - Added the `cross_origin` configuration entry, grouping every cross-origin diff --git a/lib/src/bones_api_base.dart b/lib/src/bones_api_base.dart index 6af8f26..fe3e416 100644 --- a/lib/src/bones_api_base.dart +++ b/lib/src/bones_api_base.dart @@ -48,7 +48,7 @@ typedef APILogger = /// Bones API Library class. class BonesAPI { // ignore: constant_identifier_names - static const String VERSION = '1.16.0'; + static const String VERSION = '1.16.1'; static bool _boot = false; diff --git a/pubspec.yaml b/pubspec.yaml index 377b86e..97646f1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: bones_api description: Bones_API - A powerful API backend framework for Dart. It comes with a built-in HTTP Server, route handler, entity handler, SQL translator, and DB adapters. -version: 1.16.0 +version: 1.16.1 homepage: https://github.com/Colossus-Services/bones_api environment: @@ -12,7 +12,7 @@ executables: dependencies: async_extension: ^1.2.22 async_events: ^1.3.0 - reflection_factory: ^2.9.0 + reflection_factory: ^2.10.0 statistics: ^1.2.1 swiss_knife: ^3.3.14 data_serializer: ^1.2.1 diff --git a/test/bones_api_route_enum_parameter_test.dart b/test/bones_api_route_enum_parameter_test.dart new file mode 100644 index 0000000..955090c --- /dev/null +++ b/test/bones_api_route_enum_parameter_test.dart @@ -0,0 +1,222 @@ +@TestOn('vm') +import 'package:bones_api/bones_api.dart'; +import 'package:test/test.dart'; + +part 'bones_api_route_enum_parameter_test.reflection.g.dart'; + +@EnableReflection() +enum PaymentType { creditCard, debitCard, pix } + +@EnableReflection() +enum Currency { brl, usd, eur } + +class EnumParameterAPIRoot extends APIRoot { + EnumParameterAPIRoot() : super('enum-parameter-test', '1.0'); + + @override + Set loadModules() => {ExternalIntegrationModule(this)}; +} + +@EnableReflection() +class ExternalIntegrationModule extends APIModule { + ExternalIntegrationModule(APIRoot apiRoot) + : super(apiRoot, 'external_integration'); + + @override + void configure() { + routes.anyFrom(reflection); + } + + APIResponse updateOrderStatusFromBroker( + int orderId, + String status, + bool paid, + PaymentType? paymentType, + Currency? chargedCurrency, + double? chargedPrice, + ) => APIResponse.ok({ + 'orderId': orderId, + 'status': status, + 'paid': paid, + 'paymentType': paymentType?.name, + 'chargedCurrency': chargedCurrency?.name, + 'chargedPrice': chargedPrice, + }); +} + +void main() { + group('APIRoute enum parameter', () { + setUpAll(() { + ExternalIntegrationModule$reflection.boot(); + }); + + test('enum parameter from `String` (enum name)', () async { + var apiRoot = EnumParameterAPIRoot(); + + var response = await apiRoot.call( + APIRequest.post( + '/external_integration/updateOrderStatusFromBroker', + parameters: { + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': 'creditCard', + 'chargedCurrency': 'brl', + 'chargedPrice': 12.89, + }, + ), + ); + + expect(response.error, isNull, reason: '${response.error}'); + + expect( + response.payload, + equals({ + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': 'creditCard', + 'chargedCurrency': 'brl', + 'chargedPrice': 12.89, + }), + ); + + apiRoot.close(); + }); + + test('enum parameter from `String` (qualified enum name)', () async { + var apiRoot = EnumParameterAPIRoot(); + + var response = await apiRoot.call( + APIRequest.post( + '/external_integration/updateOrderStatusFromBroker', + parameters: { + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': 'PaymentType.creditCard', + 'chargedCurrency': 'Currency.brl', + 'chargedPrice': 12.89, + }, + ), + ); + + expect(response.error, isNull, reason: '${response.error}'); + + expect( + response.payload, + equals({ + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': 'creditCard', + 'chargedCurrency': 'brl', + 'chargedPrice': 12.89, + }), + ); + + apiRoot.close(); + }); + + test('enum parameter from `String` (case insensitive)', () async { + var apiRoot = EnumParameterAPIRoot(); + + var response = await apiRoot.call( + APIRequest.post( + '/external_integration/updateOrderStatusFromBroker', + parameters: { + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': 'CreditCard', + 'chargedCurrency': 'BRL', + 'chargedPrice': 12.89, + }, + ), + ); + + expect(response.error, isNull, reason: '${response.error}'); + + expect( + response.payload, + equals({ + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': 'creditCard', + 'chargedCurrency': 'brl', + 'chargedPrice': 12.89, + }), + ); + + apiRoot.close(); + }); + + test('enum parameter from JSON payload', () async { + var apiRoot = EnumParameterAPIRoot(); + + var response = await apiRoot.call( + APIRequest.post( + '/external_integration/updateOrderStatusFromBroker', + payload: { + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': 'creditCard', + 'chargedCurrency': 'brl', + 'chargedPrice': 12.89, + }, + payloadMimeType: 'json', + ), + ); + + expect(response.error, isNull, reason: '${response.error}'); + + expect( + response.payload, + equals({ + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': 'creditCard', + 'chargedCurrency': 'brl', + 'chargedPrice': 12.89, + }), + ); + + apiRoot.close(); + }); + + test('null enum parameter', () async { + var apiRoot = EnumParameterAPIRoot(); + + var response = await apiRoot.call( + APIRequest.post( + '/external_integration/updateOrderStatusFromBroker', + parameters: { + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'chargedPrice': 12.89, + }, + ), + ); + + expect(response.error, isNull, reason: '${response.error}'); + + expect( + response.payload, + equals({ + 'orderId': 198945, + 'status': 'canceled', + 'paid': false, + 'paymentType': null, + 'chargedCurrency': null, + 'chargedPrice': 12.89, + }), + ); + + apiRoot.close(); + }); + }); +} diff --git a/test/bones_api_route_enum_parameter_test.reflection.g.dart b/test/bones_api_route_enum_parameter_test.reflection.g.dart new file mode 100644 index 0000000..d07df0c --- /dev/null +++ b/test/bones_api_route_enum_parameter_test.reflection.g.dart @@ -0,0 +1,1277 @@ +// +// GENERATED CODE - DO NOT MODIFY BY HAND! +// BUILDER: reflection_factory/2.10.0 +// BUILD COMMAND: dart run build_runner build +// + +// coverage:ignore-file +// ignore_for_file: unused_element +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: camel_case_types +// ignore_for_file: camel_case_extensions +// ignore_for_file: deprecated_member_use +// ignore_for_file: deprecated_member_use_from_same_package +// ignore_for_file: unnecessary_const +// ignore_for_file: unnecessary_cast +// ignore_for_file: unnecessary_type_check + +part of 'bones_api_route_enum_parameter_test.dart'; + +typedef __TR = TypeReflection; +typedef __TI = TypeInfo; +typedef __PR = ParameterReflection; + +mixin __ReflectionMixin { + static final Version _version = Version.parse('2.10.0'); + + Version get reflectionFactoryVersion => _version; + + List siblingsReflection() => _siblingsReflection(); +} + +Symbol? _getSymbol(String? key) { + if (key == null) return null; + + switch (key) { + case r"config": + return const Symbol(r"config"); + case r"method": + return const Symbol(r"method"); + case r"parameters": + return const Symbol(r"parameters"); + case r"parent": + return const Symbol(r"parent"); + case r"rules": + return const Symbol(r"rules"); + default: + return null; + } +} + +// ignore: non_constant_identifier_names +Currency? Currency$from(Object? o) => + Currency$reflection.staticInstance.from(o); +// ignore: non_constant_identifier_names +ExternalIntegrationModule ExternalIntegrationModule$fromJson( + Map map, +) => ExternalIntegrationModule$reflection.staticInstance.fromJson(map); +// ignore: non_constant_identifier_names +ExternalIntegrationModule ExternalIntegrationModule$fromJsonEncoded( + String jsonEncoded, +) => ExternalIntegrationModule$reflection.staticInstance.fromJsonEncoded( + jsonEncoded, +); +// ignore: non_constant_identifier_names +PaymentType? PaymentType$from(Object? o) => + PaymentType$reflection.staticInstance.from(o); + +class Currency$reflection extends EnumReflection + with __ReflectionMixin { + static final Expando _objectReflections = Expando(); + + factory Currency$reflection([Currency? object]) { + if (object == null) return staticInstance; + return _objectReflections[object] ??= Currency$reflection._(object); + } + + Currency$reflection._([Currency? object]) + : super(Currency, r'Currency', object); + + static bool _registered = false; + @override + void register() { + if (!_registered) { + _registered = true; + super.register(); + _registerSiblingsReflection(); + } + } + + @override + Version get languageVersion => Version.parse('3.10.0'); + + @override + Currency$reflection withObject([Currency? obj]) => Currency$reflection(obj); + + static Currency$reflection? _withoutObjectInstance; + @override + Currency$reflection withoutObjectInstance() => staticInstance; + + @override + Symbol? getSymbol(String? key) => _getSymbol(key); + + static Currency$reflection get staticInstance => + _withoutObjectInstance ??= Currency$reflection._(); + + @override + Currency$reflection getStaticInstance() => staticInstance; + + static bool _boot = false; + static void boot() { + if (_boot) return; + _boot = true; + Currency$reflection.staticInstance; + } + + static const List _classAnnotations = []; + + @override + List get classAnnotations => _classAnnotations; + + static const List _staticFieldsNames = const [ + 'brl', + 'eur', + 'usd', + ]; + + @override + List get staticFieldsNames => _staticFieldsNames; + + static const Map _valuesByName = const { + 'brl': Currency.brl, + 'eur': Currency.eur, + 'usd': Currency.usd, + }; + + @override + Map get valuesByName => _valuesByName; + @override + List get values => Currency.values; + + static const List _fieldsNames = const []; + + @override + List get fieldsNames => _fieldsNames; +} + +class ExternalIntegrationModule$reflection + extends ClassReflection + with __ReflectionMixin { + static final Expando + _objectReflections = Expando(); + + factory ExternalIntegrationModule$reflection([ + ExternalIntegrationModule? object, + ]) { + if (object == null) return staticInstance; + return _objectReflections[object] ??= + ExternalIntegrationModule$reflection._(object); + } + + ExternalIntegrationModule$reflection._([ExternalIntegrationModule? object]) + : super(ExternalIntegrationModule, r'ExternalIntegrationModule', object); + + static bool _registered = false; + @override + void register() { + if (!_registered) { + _registered = true; + super.register(); + _registerSiblingsReflection(); + } + } + + @override + Version get languageVersion => Version.parse('3.10.0'); + + @override + ExternalIntegrationModule$reflection withObject([ + ExternalIntegrationModule? obj, + ]) => ExternalIntegrationModule$reflection(obj)..setupInternalsWith(this); + + static ExternalIntegrationModule$reflection? _withoutObjectInstance; + @override + ExternalIntegrationModule$reflection withoutObjectInstance() => + staticInstance; + + @override + Symbol? getSymbol(String? key) => _getSymbol(key); + + static ExternalIntegrationModule$reflection get staticInstance => + _withoutObjectInstance ??= ExternalIntegrationModule$reflection._(); + + @override + ExternalIntegrationModule$reflection getStaticInstance() => staticInstance; + + static bool _boot = false; + static void boot() { + if (_boot) return; + _boot = true; + ExternalIntegrationModule$reflection.staticInstance; + } + + @override + bool get hasDefaultConstructor => false; + @override + ExternalIntegrationModule? createInstanceWithDefaultConstructor() => null; + + @override + bool get hasEmptyConstructor => false; + @override + ExternalIntegrationModule? createInstanceWithEmptyConstructor() => null; + @override + bool get hasNoRequiredArgsConstructor => false; + @override + ExternalIntegrationModule? createInstanceWithNoRequiredArgsConstructor() => + null; + + static const List _constructorsNames = const ['']; + + @override + List get constructorsNames => _constructorsNames; + + static final Map> + _constructors = {}; + + @override + ConstructorReflection? constructor( + String constructorName, + ) { + var c = _constructors[constructorName]; + if (c != null) return c; + c = _constructorImpl(constructorName); + if (c == null) return null; + _constructors[constructorName] = c; + return c; + } + + ConstructorReflection? _constructorImpl( + String constructorName, + ) { + var lc = constructorName.trim().toLowerCase(); + + switch (lc) { + case '': + return ConstructorReflection( + this, + ExternalIntegrationModule, + '', + () => ExternalIntegrationModule.new, + const <__PR>[__PR(__TR(APIRoot), 'apiRoot', false, true)], + null, + null, + null, + ); + default: + return null; + } + } + + static const List _classAnnotations = []; + + @override + List get classAnnotations => _classAnnotations; + + static const List _supperTypes = const [APIModule, Initializable]; + + @override + List get supperTypes => _supperTypes; + + @override + bool get hasMethodToJson => false; + + @override + Object? callMethodToJson([ExternalIntegrationModule? obj]) => null; + + static const List _fieldsNames = const [ + 'allRoutesNames', + 'apiConfig', + 'apiRoot', + 'authenticationRoute', + 'defaultRouteName', + 'hashCode', + 'initializationStatus', + 'isAsyncInitialization', + 'isInitialized', + 'isInitializing', + 'name', + 'routes', + 'security', + 'version', + ]; + + @override + List get fieldsNames => _fieldsNames; + + static final Map> + _fieldsNoObject = {}; + + final Map> + _fieldsObject = {}; + + @override + FieldReflection? field( + String fieldName, [ + ExternalIntegrationModule? obj, + ]) { + if (obj == null) { + if (object != null) { + return _fieldObjectImpl(fieldName); + } else { + return _fieldNoObjectImpl(fieldName); + } + } else if (identical(obj, object)) { + return _fieldObjectImpl(fieldName); + } + return _fieldNoObjectImpl(fieldName)?.withObject(obj); + } + + FieldReflection? _fieldNoObjectImpl( + String fieldName, + ) { + final f = _fieldsNoObject[fieldName]; + if (f != null) { + return f as FieldReflection; + } + final f2 = _fieldImpl(fieldName, null); + if (f2 == null) return null; + _fieldsNoObject[fieldName] = f2; + return f2 as FieldReflection; + } + + FieldReflection? _fieldObjectImpl( + String fieldName, + ) { + final f = _fieldsObject[fieldName]; + if (f != null) { + return f as FieldReflection; + } + var f2 = _fieldNoObjectImpl(fieldName); + if (f2 == null) return null; + f2 = f2.withObject(object!); + _fieldsObject[fieldName] = f2; + return f2; + } + + FieldReflection? _fieldImpl( + String fieldName, + ExternalIntegrationModule? obj, + ) { + obj ??= object; + + var lc = fieldName.trim().toLowerCase(); + + switch (lc) { + case 'apiroot': + return FieldReflection( + this, + APIModule, + const __TR(APIRoot), + 'apiRoot', + false, + (o) => + () => o!.apiRoot, + null, + obj, + true, + ); + case 'name': + return FieldReflection( + this, + APIModule, + __TR.tString, + 'name', + false, + (o) => + () => o!.name, + null, + obj, + true, + ); + case 'version': + return FieldReflection( + this, + APIModule, + __TR.tString, + 'version', + true, + (o) => + () => o!.version, + null, + obj, + true, + ); + case 'apiconfig': + return FieldReflection( + this, + APIModule, + const __TR(APIConfig), + 'apiConfig', + false, + (o) => + () => o!.apiConfig, + null, + obj, + false, + ); + case 'defaultroutename': + return FieldReflection( + this, + APIModule, + __TR.tString, + 'defaultRouteName', + true, + (o) => + () => o!.defaultRouteName, + null, + obj, + false, + ); + case 'allroutesnames': + return FieldReflection>( + this, + APIModule, + __TR.tSetString, + 'allRoutesNames', + false, + (o) => + () => o!.allRoutesNames, + null, + obj, + false, + ); + case 'routes': + return FieldReflection< + ExternalIntegrationModule, + APIRouteBuilder + >( + this, + APIModule, + const __TR>(APIRouteBuilder, <__TR>[ + __TR(APIModule), + ]), + 'routes', + false, + (o) => + () => o!.routes, + null, + obj, + false, + ); + case 'authenticationroute': + return FieldReflection( + this, + APIModule, + __TR.tString, + 'authenticationRoute', + false, + (o) => + () => o!.authenticationRoute, + null, + obj, + false, + ); + case 'security': + return FieldReflection( + this, + APIModule, + const __TR(APISecurity), + 'security', + true, + (o) => + () => o!.security, + null, + obj, + false, + ); + case 'hashcode': + return FieldReflection( + this, + APIModule, + __TR.tInt, + 'hashCode', + false, + (o) => + () => o!.hashCode, + null, + obj, + false, + const [override], + ); + case 'initializationstatus': + return FieldReflection( + this, + Initializable, + const __TR(InitializationStatus), + 'initializationStatus', + false, + (o) => + () => o!.initializationStatus, + null, + obj, + false, + ); + case 'isinitialized': + return FieldReflection( + this, + Initializable, + __TR.tBool, + 'isInitialized', + false, + (o) => + () => o!.isInitialized, + null, + obj, + false, + ); + case 'isinitializing': + return FieldReflection( + this, + Initializable, + __TR.tBool, + 'isInitializing', + false, + (o) => + () => o!.isInitializing, + null, + obj, + false, + ); + case 'isasyncinitialization': + return FieldReflection( + this, + Initializable, + __TR.tBool, + 'isAsyncInitialization', + false, + (o) => + () => o!.isAsyncInitialization, + null, + obj, + false, + ); + default: + return null; + } + } + + @override + Map getFieldsValues( + ExternalIntegrationModule? obj, { + bool withHashCode = false, + }) { + obj ??= object; + return { + 'apiRoot': obj?.apiRoot, + 'name': obj?.name, + 'version': obj?.version, + 'apiConfig': obj?.apiConfig, + 'defaultRouteName': obj?.defaultRouteName, + 'allRoutesNames': obj?.allRoutesNames, + 'routes': obj?.routes, + 'authenticationRoute': obj?.authenticationRoute, + 'security': obj?.security, + 'initializationStatus': obj?.initializationStatus, + 'isInitialized': obj?.isInitialized, + 'isInitializing': obj?.isInitializing, + 'isAsyncInitialization': obj?.isAsyncInitialization, + if (withHashCode) 'hashCode': obj?.hashCode, + }; + } + + static const List _staticFieldsNames = const []; + + @override + List get staticFieldsNames => _staticFieldsNames; + + @override + StaticFieldReflection? staticField( + String fieldName, + ) => null; + + static const List _methodsNames = const [ + 'acceptsRequest', + 'addRoute', + 'addRouteHandler', + 'apiInfo', + 'call', + 'checkInitialized', + 'configure', + 'doInitialization', + 'ensureConfigured', + 'ensureInitialized', + 'ensureInitializedAsync', + 'executeInitialized', + 'getRouteHandler', + 'getRouteHandlerByRequest', + 'getRoutesHandlersNames', + 'initialize', + 'initializeDependencies', + 'resolveRoute', + 'updateOrderStatusFromBroker', + ]; + + @override + List get methodsNames => _methodsNames; + + static final Map> + _methodsNoObject = {}; + + final Map> + _methodsObject = {}; + + @override + MethodReflection? method( + String methodName, [ + ExternalIntegrationModule? obj, + ]) { + if (obj == null) { + if (object != null) { + return _methodObjectImpl(methodName); + } else { + return _methodNoObjectImpl(methodName); + } + } else if (identical(obj, object)) { + return _methodObjectImpl(methodName); + } + return _methodNoObjectImpl(methodName)?.withObject(obj); + } + + MethodReflection? _methodNoObjectImpl( + String methodName, + ) { + final m = _methodsNoObject[methodName]; + if (m != null) { + return m as MethodReflection; + } + final m2 = _methodImpl(methodName, null); + if (m2 == null) return null; + _methodsNoObject[methodName] = m2; + return m2 as MethodReflection; + } + + MethodReflection? _methodObjectImpl( + String methodName, + ) { + final m = _methodsObject[methodName]; + if (m != null) { + return m as MethodReflection; + } + var m2 = _methodNoObjectImpl(methodName); + if (m2 == null) return null; + m2 = m2.withObject(object!); + _methodsObject[methodName] = m2; + return m2; + } + + MethodReflection? _methodImpl( + String methodName, + ExternalIntegrationModule? obj, + ) { + obj ??= object; + + var lc = methodName.trim().toLowerCase(); + + switch (lc) { + case 'configure': + return MethodReflection( + this, + ExternalIntegrationModule, + 'configure', + __TR.tVoid, + false, + (o) => o!.configure, + obj, + null, + null, + null, + const [override], + ); + case 'updateorderstatusfrombroker': + return MethodReflection< + ExternalIntegrationModule, + APIResponse> + >( + this, + ExternalIntegrationModule, + 'updateOrderStatusFromBroker', + const __TR>(APIResponse, <__TR>[ + __TR>(Map, <__TR>[ + __TR.tDynamic, + __TR.tDynamic, + ]), + ]), + false, + (o) => o!.updateOrderStatusFromBroker, + obj, + const <__PR>[ + __PR(__TR.tInt, 'orderId', false, true), + __PR(__TR.tString, 'status', false, true), + __PR(__TR.tBool, 'paid', false, true), + __PR(__TR(PaymentType), 'paymentType', true, true), + __PR(__TR(Currency), 'chargedCurrency', true, true), + __PR(__TR.tDouble, 'chargedPrice', true, true), + ], + null, + null, + null, + ); + case 'ensureconfigured': + return MethodReflection( + this, + APIModule, + 'ensureConfigured', + __TR.tVoid, + false, + (o) => o!.ensureConfigured, + obj, + null, + null, + null, + null, + ); + case 'initialize': + return MethodReflection< + ExternalIntegrationModule, + FutureOr + >( + this, + APIModule, + 'initialize', + const __TR>(FutureOr, <__TR>[ + __TR(InitializationResult), + ]), + false, + (o) => o!.initialize, + obj, + null, + null, + null, + const [override], + ); + case 'getrouteshandlersnames': + return MethodReflection>( + this, + APIModule, + 'getRoutesHandlersNames', + const __TR>(Iterable, <__TR>[__TR.tString]), + false, + (o) => o!.getRoutesHandlersNames, + obj, + null, + null, + const { + 'method': __PR( + __TR(APIRequestMethod), + 'method', + true, + false, + ), + }, + null, + ); + case 'addroute': + return MethodReflection( + this, + APIModule, + 'addRoute', + const __TR(APIModule), + false, + (o) => o!.addRoute, + obj, + const <__PR>[ + __PR( + __TR(APIRequestMethod), + 'method', + true, + true, + ), + __PR(__TR.tString, 'name', false, true), + __PR( + __TR>(APIRouteFunction, <__TR>[ + __TR.tDynamic, + ]), + 'function', + false, + true, + ), + ], + null, + const { + 'config': __PR( + __TR(APIRouteConfig), + 'config', + true, + false, + ), + 'parameters': __PR( + __TR>(Map, <__TR>[ + __TR.tString, + __TR>(TypeInfo, <__TR>[__TR.tDynamic]), + ]), + 'parameters', + true, + false, + ), + 'rules': __PR( + __TR>(Iterable, <__TR>[ + __TR(APIRouteRule), + ]), + 'rules', + true, + false, + ), + }, + null, + ); + case 'addroutehandler': + return MethodReflection( + this, + APIModule, + 'addRouteHandler', + const __TR(APIModule), + false, + (o) => o!.addRouteHandler, + obj, + const <__PR>[ + __PR( + __TR>(APIRouteHandler, <__TR>[ + __TR.tDynamic, + ]), + 'routeHandler', + false, + true, + ), + ], + null, + null, + null, + ); + case 'getroutehandler': + return MethodReflection< + ExternalIntegrationModule, + APIRouteHandler? + >( + this, + APIModule, + 'getRouteHandler', + const __TR>(APIRouteHandler, <__TR>[ + __TR.tDynamic, + ]), + true, + (o) => o!.getRouteHandler, + obj, + const <__PR>[__PR(__TR.tString, 'name', false, true)], + const <__PR>[ + __PR( + __TR(APIRequestMethod), + 'method', + true, + false, + ), + ], + null, + null, + ); + case 'getroutehandlerbyrequest': + return MethodReflection< + ExternalIntegrationModule, + APIRouteHandler? + >( + this, + APIModule, + 'getRouteHandlerByRequest', + const __TR>(APIRouteHandler, <__TR>[ + __TR.tDynamic, + ]), + true, + (o) => o!.getRouteHandlerByRequest, + obj, + const <__PR>[ + __PR(__TR(APIRequest), 'request', false, true), + ], + const <__PR>[__PR(__TR.tString, 'routeName', true, false)], + null, + null, + ); + case 'resolveroute': + return MethodReflection( + this, + APIModule, + 'resolveRoute', + __TR.tString, + false, + (o) => o!.resolveRoute, + obj, + const <__PR>[ + __PR(__TR(APIRequest), 'request', false, true), + ], + null, + null, + null, + ); + case 'call': + return MethodReflection< + ExternalIntegrationModule, + FutureOr> + >( + this, + APIModule, + 'call', + const __TR>(FutureOr, <__TR>[ + __TR>(APIResponse, <__TR>[__TR.tDynamic]), + ]), + false, + (o) => o!.call, + obj, + const <__PR>[ + __PR(__TR(APIRequest), 'request', false, true), + ], + null, + null, + null, + ); + case 'acceptsrequest': + return MethodReflection( + this, + APIModule, + 'acceptsRequest', + __TR.tBool, + false, + (o) => o!.acceptsRequest, + obj, + const <__PR>[ + __PR(__TR(APIRequest), 'apiRequest', false, true), + ], + null, + null, + null, + ); + case 'apiinfo': + return MethodReflection( + this, + APIModule, + 'apiInfo', + const __TR(APIModuleInfo), + false, + (o) => o!.apiInfo, + obj, + null, + const <__PR>[ + __PR(__TR(APIRequest), 'apiRequest', true, false), + ], + null, + null, + ); + case 'ensureinitialized': + return MethodReflection< + ExternalIntegrationModule, + FutureOr + >( + this, + Initializable, + 'ensureInitialized', + const __TR>(FutureOr, <__TR>[ + __TR(InitializationResult), + ]), + false, + (o) => o!.ensureInitialized, + obj, + null, + null, + const { + 'parent': __PR( + __TR(Initializable), + 'parent', + true, + false, + ), + }, + null, + ); + case 'ensureinitializedasync': + return MethodReflection< + ExternalIntegrationModule, + FutureOr + >( + this, + Initializable, + 'ensureInitializedAsync', + const __TR>(FutureOr, <__TR>[ + __TR(InitializationResult), + ]), + false, + (o) => o!.ensureInitializedAsync, + obj, + null, + null, + const { + 'parent': __PR( + __TR(Initializable), + 'parent', + true, + false, + ), + }, + null, + ); + case 'doinitialization': + return MethodReflection< + ExternalIntegrationModule, + FutureOr + >( + this, + Initializable, + 'doInitialization', + const __TR>(FutureOr, <__TR>[ + __TR(InitializationResult), + ]), + false, + (o) => o!.doInitialization, + obj, + null, + null, + const { + 'parent': __PR( + __TR(Initializable), + 'parent', + true, + false, + ), + }, + null, + ); + case 'initializedependencies': + return MethodReflection< + ExternalIntegrationModule, + FutureOr> + >( + this, + Initializable, + 'initializeDependencies', + const __TR>>(FutureOr, <__TR>[ + __TR>(List, <__TR>[ + __TR(Initializable), + ]), + ]), + false, + (o) => o!.initializeDependencies, + obj, + null, + null, + null, + null, + ); + case 'checkinitialized': + return MethodReflection( + this, + Initializable, + 'checkInitialized', + __TR.tVoid, + false, + (o) => o!.checkInitialized, + obj, + null, + null, + null, + null, + ); + case 'executeinitialized': + return MethodReflection>( + this, + Initializable, + 'executeInitialized', + __TR.tFutureOrDynamic, + false, + (o) => o!.executeInitialized, + obj, + const <__PR>[ + __PR( + __TR>( + ExecuteInitializedCallback, + <__TR>[__TR.tDynamic], + ), + 'callback', + false, + true, + ), + ], + null, + const { + 'parent': __PR( + __TR(Initializable), + 'parent', + true, + false, + ), + }, + null, + ); + default: + return null; + } + } + + static const List _staticMethodsNames = const []; + + @override + List get staticMethodsNames => _staticMethodsNames; + + @override + StaticMethodReflection? staticMethod( + String methodName, + ) => null; +} + +class PaymentType$reflection extends EnumReflection + with __ReflectionMixin { + static final Expando _objectReflections = Expando(); + + factory PaymentType$reflection([PaymentType? object]) { + if (object == null) return staticInstance; + return _objectReflections[object] ??= PaymentType$reflection._(object); + } + + PaymentType$reflection._([PaymentType? object]) + : super(PaymentType, r'PaymentType', object); + + static bool _registered = false; + @override + void register() { + if (!_registered) { + _registered = true; + super.register(); + _registerSiblingsReflection(); + } + } + + @override + Version get languageVersion => Version.parse('3.10.0'); + + @override + PaymentType$reflection withObject([PaymentType? obj]) => + PaymentType$reflection(obj); + + static PaymentType$reflection? _withoutObjectInstance; + @override + PaymentType$reflection withoutObjectInstance() => staticInstance; + + @override + Symbol? getSymbol(String? key) => _getSymbol(key); + + static PaymentType$reflection get staticInstance => + _withoutObjectInstance ??= PaymentType$reflection._(); + + @override + PaymentType$reflection getStaticInstance() => staticInstance; + + static bool _boot = false; + static void boot() { + if (_boot) return; + _boot = true; + PaymentType$reflection.staticInstance; + } + + static const List _classAnnotations = []; + + @override + List get classAnnotations => _classAnnotations; + + static const List _staticFieldsNames = const [ + 'creditCard', + 'debitCard', + 'pix', + ]; + + @override + List get staticFieldsNames => _staticFieldsNames; + + static const Map _valuesByName = + const { + 'creditCard': PaymentType.creditCard, + 'debitCard': PaymentType.debitCard, + 'pix': PaymentType.pix, + }; + + @override + Map get valuesByName => _valuesByName; + @override + List get values => PaymentType.values; + + static const List _fieldsNames = const []; + + @override + List get fieldsNames => _fieldsNames; +} + +extension Currency$reflectionExtension on Currency { + /// Returns a [EnumReflection] for type [Currency]. (Generated by [ReflectionFactory]) + EnumReflection get reflection => Currency$reflection(this); + + /// Returns the name of the [Currency] instance. (Generated by [ReflectionFactory]) + String get enumName => Currency$reflection(this).name()!; + + /// Returns a JSON for type [Currency]. (Generated by [ReflectionFactory]) + String? toJson() => reflection.toJson(); + + /// Returns a JSON [Map] for type [Currency]. (Generated by [ReflectionFactory]) + Map? toJsonMap() => reflection.toJsonMap(); + + /// Returns an encoded JSON [String] for type [Currency]. (Generated by [ReflectionFactory]) + String toJsonEncoded({bool pretty = false}) => + reflection.toJsonEncoded(pretty: pretty); +} + +extension ExternalIntegrationModule$reflectionExtension + on ExternalIntegrationModule { + /// Returns a [ClassReflection] for type [ExternalIntegrationModule]. (Generated by [ReflectionFactory]) + ClassReflection get reflection => + ExternalIntegrationModule$reflection(this); + + /// Returns a JSON for type [ExternalIntegrationModule]. (Generated by [ReflectionFactory]) + Object? toJson({bool duplicatedEntitiesAsID = false}) => + reflection.toJson(null, null, duplicatedEntitiesAsID); + + /// Returns a JSON [Map] for type [ExternalIntegrationModule]. (Generated by [ReflectionFactory]) + Map? toJsonMap({bool duplicatedEntitiesAsID = false}) => + reflection.toJsonMap(duplicatedEntitiesAsID: duplicatedEntitiesAsID); + + /// Returns an encoded JSON [String] for type [ExternalIntegrationModule]. (Generated by [ReflectionFactory]) + String toJsonEncoded({ + bool pretty = false, + bool duplicatedEntitiesAsID = false, + }) => reflection.toJsonEncoded( + pretty: pretty, + duplicatedEntitiesAsID: duplicatedEntitiesAsID, + ); + + /// Returns a JSON for type [ExternalIntegrationModule] using the class fields. (Generated by [ReflectionFactory]) + Object? toJsonFromFields({bool duplicatedEntitiesAsID = false}) => reflection + .toJsonFromFields(duplicatedEntitiesAsID: duplicatedEntitiesAsID); +} + +extension PaymentType$reflectionExtension on PaymentType { + /// Returns a [EnumReflection] for type [PaymentType]. (Generated by [ReflectionFactory]) + EnumReflection get reflection => PaymentType$reflection(this); + + /// Returns the name of the [PaymentType] instance. (Generated by [ReflectionFactory]) + String get enumName => PaymentType$reflection(this).name()!; + + /// Returns a JSON for type [PaymentType]. (Generated by [ReflectionFactory]) + String? toJson() => reflection.toJson(); + + /// Returns a JSON [Map] for type [PaymentType]. (Generated by [ReflectionFactory]) + Map? toJsonMap() => reflection.toJsonMap(); + + /// Returns an encoded JSON [String] for type [PaymentType]. (Generated by [ReflectionFactory]) + String toJsonEncoded({bool pretty = false}) => + reflection.toJsonEncoded(pretty: pretty); +} + +List _listSiblingsReflection() => [ + Currency$reflection(), + ExternalIntegrationModule$reflection(), + PaymentType$reflection(), +]; + +List? _siblingsReflectionList; +List _siblingsReflection() => _siblingsReflectionList ??= + List.unmodifiable(_listSiblingsReflection()); + +bool _registerSiblingsReflectionCalled = false; +void _registerSiblingsReflection() { + if (_registerSiblingsReflectionCalled) return; + _registerSiblingsReflectionCalled = true; + var length = _listSiblingsReflection().length; + assert(length > 0); +} diff --git a/test/bones_api_test.reflection.g.dart b/test/bones_api_test.reflection.g.dart index 5004849..27f1255 100644 --- a/test/bones_api_test.reflection.g.dart +++ b/test/bones_api_test.reflection.g.dart @@ -1,6 +1,6 @@ // // GENERATED CODE - DO NOT MODIFY BY HAND! -// BUILDER: reflection_factory/2.9.0 +// BUILDER: reflection_factory/2.10.0 // BUILD COMMAND: dart run build_runner build // @@ -22,7 +22,7 @@ typedef __TI = TypeInfo; typedef __PR = ParameterReflection; mixin __ReflectionMixin { - static final Version _version = Version.parse('2.9.0'); + static final Version _version = Version.parse('2.10.0'); Version get reflectionFactoryVersion => _version; diff --git a/test/bones_api_test_entities.reflection.g.dart b/test/bones_api_test_entities.reflection.g.dart index 2507057..b11c3d8 100644 --- a/test/bones_api_test_entities.reflection.g.dart +++ b/test/bones_api_test_entities.reflection.g.dart @@ -1,6 +1,6 @@ // // GENERATED CODE - DO NOT MODIFY BY HAND! -// BUILDER: reflection_factory/2.9.0 +// BUILDER: reflection_factory/2.10.0 // BUILD COMMAND: dart run build_runner build // @@ -22,7 +22,7 @@ typedef __TI = TypeInfo; typedef __PR = ParameterReflection; mixin __ReflectionMixin { - static final Version _version = Version.parse('2.9.0'); + static final Version _version = Version.parse('2.10.0'); Version get reflectionFactoryVersion => _version; diff --git a/test/bones_api_test_entities_orders.reflection.g.dart b/test/bones_api_test_entities_orders.reflection.g.dart index 3121a4c..6029063 100644 --- a/test/bones_api_test_entities_orders.reflection.g.dart +++ b/test/bones_api_test_entities_orders.reflection.g.dart @@ -1,6 +1,6 @@ // // GENERATED CODE - DO NOT MODIFY BY HAND! -// BUILDER: reflection_factory/2.9.0 +// BUILDER: reflection_factory/2.10.0 // BUILD COMMAND: dart run build_runner build // @@ -22,7 +22,7 @@ typedef __TI = TypeInfo; typedef __PR = ParameterReflection; mixin __ReflectionMixin { - static final Version _version = Version.parse('2.9.0'); + static final Version _version = Version.parse('2.10.0'); Version get reflectionFactoryVersion => _version; diff --git a/test/bones_api_test_modules.reflection.g.dart b/test/bones_api_test_modules.reflection.g.dart index 6470a24..ff70432 100644 --- a/test/bones_api_test_modules.reflection.g.dart +++ b/test/bones_api_test_modules.reflection.g.dart @@ -1,6 +1,6 @@ // // GENERATED CODE - DO NOT MODIFY BY HAND! -// BUILDER: reflection_factory/2.9.0 +// BUILDER: reflection_factory/2.10.0 // BUILD COMMAND: dart run build_runner build // @@ -22,7 +22,7 @@ typedef __TI = TypeInfo; typedef __PR = ParameterReflection; mixin __ReflectionMixin { - static final Version _version = Version.parse('2.9.0'); + static final Version _version = Version.parse('2.10.0'); Version get reflectionFactoryVersion => _version; diff --git a/test/bones_api_test_utils_test.reflection.g.dart b/test/bones_api_test_utils_test.reflection.g.dart index 8ace306..8c22f47 100644 --- a/test/bones_api_test_utils_test.reflection.g.dart +++ b/test/bones_api_test_utils_test.reflection.g.dart @@ -1,6 +1,6 @@ // // GENERATED CODE - DO NOT MODIFY BY HAND! -// BUILDER: reflection_factory/2.9.0 +// BUILDER: reflection_factory/2.10.0 // BUILD COMMAND: dart run build_runner build // @@ -22,7 +22,7 @@ typedef __TI = TypeInfo; typedef __PR = ParameterReflection; mixin __ReflectionMixin { - static final Version _version = Version.parse('2.9.0'); + static final Version _version = Version.parse('2.10.0'); Version get reflectionFactoryVersion => _version; From cdf2ec1189042a6e57bf173c7ddf446bd3e0b700 Mon Sep 17 00:00:00 2001 From: "Graciliano M. P." Date: Tue, 1 Sep 2026 23:50:41 -0300 Subject: [PATCH 2/2] chore: drop `final` from the parameters `dependency_validator` rejects `dependency_validator` 5.0.6 fails to parse a `final` modifier on a formal parameter, and the CI `build` job runs it: Error parsing: ./lib/src/bones_api_logging.dart Content produced diagnostics when parsed: extraneous_modifier: Can't have modifier 'final' here. - 513:36 The modifier only barred reassignment inside the body, so dropping it from the four parameters that carried it is a no-op. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01RVuPYBSbnLEWVqPXTcmZU2 --- lib/src/bones_api_logging.dart | 2 +- lib/src/bones_api_mixin.dart | 2 +- lib/src/bones_api_sql_builder.dart | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/bones_api_logging.dart b/lib/src/bones_api_logging.dart index 8b8ea3f..57c3478 100644 --- a/lib/src/bones_api_logging.dart +++ b/lib/src/bones_api_logging.dart @@ -510,7 +510,7 @@ abstract class LoggerHandler { } } - MessageLogger? resolveLogDestiny(final Object? logDestiny) { + MessageLogger? resolveLogDestiny(Object? logDestiny) { if (logDestiny == null) return null; if (logDestiny is Map) { diff --git a/lib/src/bones_api_mixin.dart b/lib/src/bones_api_mixin.dart index 3289c4b..49449a8 100644 --- a/lib/src/bones_api_mixin.dart +++ b/lib/src/bones_api_mixin.dart @@ -566,7 +566,7 @@ mixin FieldsFromMap { /// Resolves [fieldName] to one that matches a [fieldsNames] element. String? resolveFiledName( List fieldsNames, - final String fieldName, { + String fieldName, { Map? fieldsNamesIndexes, List? fieldsNamesLC, List? fieldsNamesSimple, diff --git a/lib/src/bones_api_sql_builder.dart b/lib/src/bones_api_sql_builder.dart index e4c9724..3978890 100644 --- a/lib/src/bones_api_sql_builder.dart +++ b/lib/src/bones_api_sql_builder.dart @@ -1044,8 +1044,8 @@ extension SQLBuilderListExtension on List { } int _bestOrderImpl( - final Map> entriesReferences, - final Map> entriesRelationships, + Map> entriesReferences, + Map> entriesRelationships, ) { final length = this.length;