Ajoute la synchronisation client incrémentale LWW vers l'API serveur (application/use_cases.dart: SyncUseCases, ports.dart, migration Drift schemaVersion 10→11 pour les métadonnées de sync et mappings de ressources, infrastructure/remote/sync_api.dart) et l'écran de profil avec entrée sur l'accueil (presentation/profile_screen.dart, home_screen.dart, presentation.dart). Développés dans le même worktree partagé par DevBackend et DevFrontend ; commit combiné car test/presentation/home_screen_test.dart mélange authentiquement les deux tickets (le test de l'entrée Profil et la mise à jour du fake de bootstrap requise par le nouveau getter syncUseCases sur AppDependencies). Corrige au passage une couleur `crimson` inexistante dans le thème (remplacée par colorScheme.error) et une signature de paramètres positionnels/nommés incohérente sur un fake de test. flutter pub get OK, build_runner OK, dart format appliqué, analyze propre (mêmes infos préexistantes), 119/119 tests verts, build APK debug validé. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -68,12 +68,55 @@ final class HttpApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
Uri _resolve(String path) {
|
||||
Future<Map<String, Object?>> getJson(
|
||||
String path, {
|
||||
Map<String, String?> queryParameters = const {},
|
||||
String? bearerToken,
|
||||
Set<int> expectedStatuses = const {200},
|
||||
}) async {
|
||||
final response = await _send(
|
||||
() => client.get(
|
||||
_resolve(path, queryParameters: queryParameters),
|
||||
headers: _headers(bearerToken),
|
||||
),
|
||||
);
|
||||
if (!expectedStatuses.contains(response.statusCode)) {
|
||||
throw _exceptionForStatus(response.statusCode, response.body);
|
||||
}
|
||||
if (response.body.trim().isEmpty) {
|
||||
return const {};
|
||||
}
|
||||
final Object? decoded;
|
||||
try {
|
||||
decoded = jsonDecode(response.body);
|
||||
} on FormatException catch (error) {
|
||||
throw RemoteAuthException(RemoteAuthFailure.unknown, error.message);
|
||||
}
|
||||
if (decoded is Map) {
|
||||
return Map<String, Object?>.from(decoded);
|
||||
}
|
||||
throw const RemoteAuthException(
|
||||
RemoteAuthFailure.unknown,
|
||||
'Unexpected JSON response.',
|
||||
);
|
||||
}
|
||||
|
||||
Uri _resolve(String path, {Map<String, String?> queryParameters = const {}}) {
|
||||
final normalized = path.startsWith('/') ? path.substring(1) : path;
|
||||
final base = baseUrl.toString().endsWith('/')
|
||||
? baseUrl
|
||||
: Uri.parse('${baseUrl.toString()}/');
|
||||
return base.resolve(normalized);
|
||||
final resolved = base.resolve(normalized);
|
||||
final cleanQuery = {
|
||||
for (final entry in queryParameters.entries)
|
||||
if (entry.value != null) entry.key: entry.value!,
|
||||
};
|
||||
if (cleanQuery.isEmpty) {
|
||||
return resolved;
|
||||
}
|
||||
return resolved.replace(
|
||||
queryParameters: {...resolved.queryParameters, ...cleanQuery},
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, String> _headers(String? bearerToken) => {
|
||||
|
||||
Reference in New Issue
Block a user