From 93b86b86f3b2c5057b1db50c56697f5a988d48cc Mon Sep 17 00:00:00 2001 From: Miguel Beltran Date: Mon, 9 Sep 2024 09:42:42 +0200 Subject: [PATCH] [Compass App] Refactor model (#2431) This PR removes the `compass_model` subproject and moves each data model class to the respective `app` or `server` project. Although this leads to code duplication, this is a more realistic implementation where clients and servers have their own respective data model class implementations. The model classes for the server are located in `server/lib/model`. Model classes for the app are located in two places: - API-only model: `app/lib/data/services/api/model`. - Domain model: `app/lib/domain/model`. In general, models located under the domain are used across the app, while the API-only models are only used for interacting with the API client. Tests have been updated. ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. [Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md [Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md --- .../activity/activity_repository.dart | 3 +- .../activity/activity_repository_local.dart | 3 +- .../activity/activity_repository_remote.dart | 3 +- .../auth/auth_repository_remote.dart | 3 +- .../booking/booking_repository.dart | 3 +- .../booking/booking_repository_local.dart | 2 +- .../booking/booking_repository_remote.dart | 5 +- .../continent/continent_repository.dart | 3 +- .../continent/continent_repository_local.dart | 3 +- .../continent_repository_remote.dart | 3 +- .../destination/destination_repository.dart | 3 +- .../destination_repository_local.dart | 3 +- .../destination_repository_remote.dart | 3 +- .../itinerary_config_repository.dart | 3 +- .../itinerary_config_repository_memory.dart | 3 +- .../app/lib/data/services/api/api_client.dart | 4 +- .../data/services/api/auth_api_client.dart | 6 +- .../model}/login_request/login_request.dart | 0 .../login_request/login_request.freezed.dart | 0 .../model}/login_request/login_request.g.dart | 0 .../model}/login_response/login_response.dart | 0 .../login_response.freezed.dart | 0 .../login_response/login_response.g.dart | 0 .../services/local/local_data_service.dart | 4 +- .../booking/booking_create_component.dart | 5 +- .../booking/booking_share_component.dart | 2 +- .../lib/domain/models}/activity/activity.dart | 0 .../models}/activity/activity.freezed.dart | 0 .../domain/models}/activity/activity.g.dart | 0 .../lib/domain/models}/booking/booking.dart | 4 +- .../models}/booking/booking.freezed.dart | 0 .../lib/domain/models}/booking/booking.g.dart | 0 .../domain/models}/continent/continent.dart | 0 .../models}/continent/continent.freezed.dart | 0 .../domain/models}/continent/continent.g.dart | 0 .../models}/destination/destination.dart | 0 .../destination/destination.freezed.dart | 0 .../models}/destination/destination.g.dart | 0 .../itinerary_config/itinerary_config.dart | 0 .../itinerary_config.freezed.dart | 0 .../itinerary_config/itinerary_config.g.dart | 0 .../view_models/activities_viewmodel.dart | 2 +- .../ui/activities/widgets/activity_entry.dart | 2 +- .../logout/view_models/logout_viewmodel.dart | 3 +- .../view_models/booking_viewmodel.dart | 3 +- .../lib/ui/booking/widgets/booking_body.dart | 2 +- .../ui/booking/widgets/booking_header.dart | 2 +- .../app/lib/ui/core/ui/search_bar.dart | 2 +- .../view_models/results_viewmodel.dart | 3 +- .../lib/ui/results/widgets/result_card.dart | 3 +- .../view_models/search_form_viewmodel.dart | 3 +- .../widgets/search_form_continent.dart | 2 +- compass_app/app/pubspec.yaml | 2 - .../booking_create_component_test.dart | 2 +- .../booking/booking_share_component_test.dart | 2 +- .../ui/activities/activities_screen_test.dart | 2 +- .../app/test/ui/auth/logout_button_test.dart | 2 +- .../test/ui/booking/booking_screen_test.dart | 2 +- .../test/ui/results/results_screen_test.dart | 2 +- .../ui/results/results_viewmodel_test.dart | 2 +- .../fake_activities_repository.dart | 2 +- .../repositories/fake_booking_repository.dart | 2 +- .../fake_continent_repository.dart | 2 +- .../fake_destination_repository.dart | 2 +- .../fake_itinerary_config_repository.dart | 2 +- .../fakes/services/fake_api_client.dart | 4 +- .../fakes/services/fake_auth_api_client.dart | 4 +- compass_app/app/testing/models/activity.dart | 2 +- compass_app/app/testing/models/booking.dart | 2 +- .../app/testing/models/destination.dart | 2 +- compass_app/model/.gitignore | 7 - compass_app/model/README.md | 3 - compass_app/model/analysis_options.yaml | 30 -- compass_app/model/lib/model.dart | 9 - compass_app/model/pubspec.yaml | 17 - compass_app/model/test/.gitkeep | 0 compass_app/server/lib/config/assets.dart | 3 +- .../server/lib/model/activity/activity.dart | 52 +++ .../lib/model/activity/activity.freezed.dart | 425 ++++++++++++++++++ .../server/lib/model/activity/activity.g.dart | 43 ++ .../server/lib/model/continent/continent.dart | 19 + .../model/continent/continent.freezed.dart | 191 ++++++++ .../lib/model/continent/continent.g.dart | 19 + .../lib/model/destination/destination.dart | 34 ++ .../destination/destination.freezed.dart | 339 ++++++++++++++ .../lib/model/destination/destination.g.dart | 29 ++ .../model/login_request/login_request.dart | 20 + .../login_request/login_request.freezed.dart | 192 ++++++++ .../model/login_request/login_request.g.dart | 19 + .../model/login_response/login_response.dart | 20 + .../login_response.freezed.dart | 191 ++++++++ .../login_response/login_response.g.dart | 19 + compass_app/server/lib/routes/continent.dart | 3 +- compass_app/server/lib/routes/login.dart | 4 +- compass_app/server/pubspec.yaml | 2 - compass_app/server/test/server_test.dart | 6 +- 96 files changed, 1693 insertions(+), 141 deletions(-) rename compass_app/{model/lib/src/model/auth => app/lib/data/services/api/model}/login_request/login_request.dart (100%) rename compass_app/{model/lib/src/model/auth => app/lib/data/services/api/model}/login_request/login_request.freezed.dart (100%) rename compass_app/{model/lib/src/model/auth => app/lib/data/services/api/model}/login_request/login_request.g.dart (100%) rename compass_app/{model/lib/src/model/auth => app/lib/data/services/api/model}/login_response/login_response.dart (100%) rename compass_app/{model/lib/src/model/auth => app/lib/data/services/api/model}/login_response/login_response.freezed.dart (100%) rename compass_app/{model/lib/src/model/auth => app/lib/data/services/api/model}/login_response/login_response.g.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/activity/activity.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/activity/activity.freezed.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/activity/activity.g.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/booking/booking.dart (87%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/booking/booking.freezed.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/booking/booking.g.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/continent/continent.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/continent/continent.freezed.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/continent/continent.g.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/destination/destination.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/destination/destination.freezed.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/destination/destination.g.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/itinerary_config/itinerary_config.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/itinerary_config/itinerary_config.freezed.dart (100%) rename compass_app/{model/lib/src/model => app/lib/domain/models}/itinerary_config/itinerary_config.g.dart (100%) delete mode 100644 compass_app/model/.gitignore delete mode 100644 compass_app/model/README.md delete mode 100644 compass_app/model/analysis_options.yaml delete mode 100644 compass_app/model/lib/model.dart delete mode 100644 compass_app/model/pubspec.yaml delete mode 100644 compass_app/model/test/.gitkeep create mode 100644 compass_app/server/lib/model/activity/activity.dart create mode 100644 compass_app/server/lib/model/activity/activity.freezed.dart create mode 100644 compass_app/server/lib/model/activity/activity.g.dart create mode 100644 compass_app/server/lib/model/continent/continent.dart create mode 100644 compass_app/server/lib/model/continent/continent.freezed.dart create mode 100644 compass_app/server/lib/model/continent/continent.g.dart create mode 100644 compass_app/server/lib/model/destination/destination.dart create mode 100644 compass_app/server/lib/model/destination/destination.freezed.dart create mode 100644 compass_app/server/lib/model/destination/destination.g.dart create mode 100644 compass_app/server/lib/model/login_request/login_request.dart create mode 100644 compass_app/server/lib/model/login_request/login_request.freezed.dart create mode 100644 compass_app/server/lib/model/login_request/login_request.g.dart create mode 100644 compass_app/server/lib/model/login_response/login_response.dart create mode 100644 compass_app/server/lib/model/login_response/login_response.freezed.dart create mode 100644 compass_app/server/lib/model/login_response/login_response.g.dart diff --git a/compass_app/app/lib/data/repositories/activity/activity_repository.dart b/compass_app/app/lib/data/repositories/activity/activity_repository.dart index 766817ccc..79e57e97a 100644 --- a/compass_app/app/lib/data/repositories/activity/activity_repository.dart +++ b/compass_app/app/lib/data/repositories/activity/activity_repository.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/activity/activity.dart'; import '../../../utils/result.dart'; /// Data source for activities. diff --git a/compass_app/app/lib/data/repositories/activity/activity_repository_local.dart b/compass_app/app/lib/data/repositories/activity/activity_repository_local.dart index 28695d59c..c5e43164b 100644 --- a/compass_app/app/lib/data/repositories/activity/activity_repository_local.dart +++ b/compass_app/app/lib/data/repositories/activity/activity_repository_local.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/activity/activity.dart'; import '../../../utils/result.dart'; import '../../services/local/local_data_service.dart'; import 'activity_repository.dart'; diff --git a/compass_app/app/lib/data/repositories/activity/activity_repository_remote.dart b/compass_app/app/lib/data/repositories/activity/activity_repository_remote.dart index 5af0b3dcb..180642ee9 100644 --- a/compass_app/app/lib/data/repositories/activity/activity_repository_remote.dart +++ b/compass_app/app/lib/data/repositories/activity/activity_repository_remote.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/activity/activity.dart'; import '../../../utils/result.dart'; import '../../services/api/api_client.dart'; import 'activity_repository.dart'; diff --git a/compass_app/app/lib/data/repositories/auth/auth_repository_remote.dart b/compass_app/app/lib/data/repositories/auth/auth_repository_remote.dart index 567aac693..a1be9b92e 100644 --- a/compass_app/app/lib/data/repositories/auth/auth_repository_remote.dart +++ b/compass_app/app/lib/data/repositories/auth/auth_repository_remote.dart @@ -1,9 +1,10 @@ -import 'package:compass_model/model.dart'; import 'package:logging/logging.dart'; import '../../../utils/result.dart'; import '../../services/api/api_client.dart'; import '../../services/api/auth_api_client.dart'; +import '../../services/api/model/login_request/login_request.dart'; +import '../../services/api/model/login_response/login_response.dart'; import '../../services/shared_preferences_service.dart'; import 'auth_repository.dart'; diff --git a/compass_app/app/lib/data/repositories/booking/booking_repository.dart b/compass_app/app/lib/data/repositories/booking/booking_repository.dart index b79be9656..747534846 100644 --- a/compass_app/app/lib/data/repositories/booking/booking_repository.dart +++ b/compass_app/app/lib/data/repositories/booking/booking_repository.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/booking/booking.dart'; import '../../../domain/models/booking/booking_summary.dart'; import '../../../utils/result.dart'; diff --git a/compass_app/app/lib/data/repositories/booking/booking_repository_local.dart b/compass_app/app/lib/data/repositories/booking/booking_repository_local.dart index cd8cd212a..b58a1dde0 100644 --- a/compass_app/app/lib/data/repositories/booking/booking_repository_local.dart +++ b/compass_app/app/lib/data/repositories/booking/booking_repository_local.dart @@ -1,7 +1,7 @@ import 'dart:async'; -import 'package:compass_model/model.dart'; import 'package:collection/collection.dart'; +import '../../../domain/models/booking/booking.dart'; import '../../../domain/models/booking/booking_summary.dart'; import '../../../utils/result.dart'; diff --git a/compass_app/app/lib/data/repositories/booking/booking_repository_remote.dart b/compass_app/app/lib/data/repositories/booking/booking_repository_remote.dart index 23938b0ce..6a436a2ec 100644 --- a/compass_app/app/lib/data/repositories/booking/booking_repository_remote.dart +++ b/compass_app/app/lib/data/repositories/booking/booking_repository_remote.dart @@ -1,6 +1,7 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/activity/activity.dart'; +import '../../../domain/models/booking/booking.dart'; import '../../../domain/models/booking/booking_summary.dart'; +import '../../../domain/models/destination/destination.dart'; import '../../../utils/result.dart'; import '../../services/api/api_client.dart'; import '../../services/api/model/booking/booking_api_model.dart'; diff --git a/compass_app/app/lib/data/repositories/continent/continent_repository.dart b/compass_app/app/lib/data/repositories/continent/continent_repository.dart index 9429684e7..7f55bfe20 100644 --- a/compass_app/app/lib/data/repositories/continent/continent_repository.dart +++ b/compass_app/app/lib/data/repositories/continent/continent_repository.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/continent/continent.dart'; import '../../../utils/result.dart'; /// Data source with all possible continents. diff --git a/compass_app/app/lib/data/repositories/continent/continent_repository_local.dart b/compass_app/app/lib/data/repositories/continent/continent_repository_local.dart index e815ced61..a0eb4a996 100644 --- a/compass_app/app/lib/data/repositories/continent/continent_repository_local.dart +++ b/compass_app/app/lib/data/repositories/continent/continent_repository_local.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/continent/continent.dart'; import '../../../utils/result.dart'; import '../../services/local/local_data_service.dart'; import 'continent_repository.dart'; diff --git a/compass_app/app/lib/data/repositories/continent/continent_repository_remote.dart b/compass_app/app/lib/data/repositories/continent/continent_repository_remote.dart index c2ff991ef..899300e27 100644 --- a/compass_app/app/lib/data/repositories/continent/continent_repository_remote.dart +++ b/compass_app/app/lib/data/repositories/continent/continent_repository_remote.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/continent/continent.dart'; import '../../../utils/result.dart'; import '../../services/api/api_client.dart'; import 'continent_repository.dart'; diff --git a/compass_app/app/lib/data/repositories/destination/destination_repository.dart b/compass_app/app/lib/data/repositories/destination/destination_repository.dart index 950235296..9ac135b6e 100644 --- a/compass_app/app/lib/data/repositories/destination/destination_repository.dart +++ b/compass_app/app/lib/data/repositories/destination/destination_repository.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/destination/destination.dart'; import '../../../utils/result.dart'; /// Data source with all possible destinations diff --git a/compass_app/app/lib/data/repositories/destination/destination_repository_local.dart b/compass_app/app/lib/data/repositories/destination/destination_repository_local.dart index 41aa8db7a..d385304b7 100644 --- a/compass_app/app/lib/data/repositories/destination/destination_repository_local.dart +++ b/compass_app/app/lib/data/repositories/destination/destination_repository_local.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/destination/destination.dart'; import '../../../utils/result.dart'; import '../../services/local/local_data_service.dart'; import 'destination_repository.dart'; diff --git a/compass_app/app/lib/data/repositories/destination/destination_repository_remote.dart b/compass_app/app/lib/data/repositories/destination/destination_repository_remote.dart index 360c2a7de..3ba8dabd2 100644 --- a/compass_app/app/lib/data/repositories/destination/destination_repository_remote.dart +++ b/compass_app/app/lib/data/repositories/destination/destination_repository_remote.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/destination/destination.dart'; import '../../../utils/result.dart'; import '../../services/api/api_client.dart'; import 'destination_repository.dart'; diff --git a/compass_app/app/lib/data/repositories/itinerary_config/itinerary_config_repository.dart b/compass_app/app/lib/data/repositories/itinerary_config/itinerary_config_repository.dart index 9202c4e89..466e20bc7 100644 --- a/compass_app/app/lib/data/repositories/itinerary_config/itinerary_config_repository.dart +++ b/compass_app/app/lib/data/repositories/itinerary_config/itinerary_config_repository.dart @@ -1,5 +1,4 @@ -import 'package:compass_model/model.dart'; - +import '../../../domain/models/itinerary_config/itinerary_config.dart'; import '../../../utils/result.dart'; /// Data source for the current [ItineraryConfig] diff --git a/compass_app/app/lib/data/repositories/itinerary_config/itinerary_config_repository_memory.dart b/compass_app/app/lib/data/repositories/itinerary_config/itinerary_config_repository_memory.dart index eb80da7a0..a1972eac6 100644 --- a/compass_app/app/lib/data/repositories/itinerary_config/itinerary_config_repository_memory.dart +++ b/compass_app/app/lib/data/repositories/itinerary_config/itinerary_config_repository_memory.dart @@ -1,7 +1,6 @@ import 'dart:async'; -import 'package:compass_model/model.dart'; - +import '../../../domain/models/itinerary_config/itinerary_config.dart'; import '../../../utils/result.dart'; import 'itinerary_config_repository.dart'; diff --git a/compass_app/app/lib/data/services/api/api_client.dart b/compass_app/app/lib/data/services/api/api_client.dart index 4bef6a049..ad98d00ab 100644 --- a/compass_app/app/lib/data/services/api/api_client.dart +++ b/compass_app/app/lib/data/services/api/api_client.dart @@ -1,7 +1,9 @@ import 'dart:convert'; import 'dart:io'; -import 'package:compass_model/model.dart'; +import '../../../domain/models/activity/activity.dart'; +import '../../../domain/models/continent/continent.dart'; +import '../../../domain/models/destination/destination.dart'; import '../../../utils/result.dart'; import 'model/booking/booking_api_model.dart'; diff --git a/compass_app/app/lib/data/services/api/auth_api_client.dart b/compass_app/app/lib/data/services/api/auth_api_client.dart index f5dbd1646..22aef8001 100644 --- a/compass_app/app/lib/data/services/api/auth_api_client.dart +++ b/compass_app/app/lib/data/services/api/auth_api_client.dart @@ -1,11 +1,11 @@ -// TODO: Configurable baseurl/host/port import 'dart:convert'; import 'dart:io'; -import 'package:compass_model/model.dart'; - import '../../../utils/result.dart'; +import 'model/login_request/login_request.dart'; +import 'model/login_response/login_response.dart'; +// TODO: Configurable baseurl/host/port class AuthApiClient { Future> login(LoginRequest loginRequest) async { final client = HttpClient(); diff --git a/compass_app/model/lib/src/model/auth/login_request/login_request.dart b/compass_app/app/lib/data/services/api/model/login_request/login_request.dart similarity index 100% rename from compass_app/model/lib/src/model/auth/login_request/login_request.dart rename to compass_app/app/lib/data/services/api/model/login_request/login_request.dart diff --git a/compass_app/model/lib/src/model/auth/login_request/login_request.freezed.dart b/compass_app/app/lib/data/services/api/model/login_request/login_request.freezed.dart similarity index 100% rename from compass_app/model/lib/src/model/auth/login_request/login_request.freezed.dart rename to compass_app/app/lib/data/services/api/model/login_request/login_request.freezed.dart diff --git a/compass_app/model/lib/src/model/auth/login_request/login_request.g.dart b/compass_app/app/lib/data/services/api/model/login_request/login_request.g.dart similarity index 100% rename from compass_app/model/lib/src/model/auth/login_request/login_request.g.dart rename to compass_app/app/lib/data/services/api/model/login_request/login_request.g.dart diff --git a/compass_app/model/lib/src/model/auth/login_response/login_response.dart b/compass_app/app/lib/data/services/api/model/login_response/login_response.dart similarity index 100% rename from compass_app/model/lib/src/model/auth/login_response/login_response.dart rename to compass_app/app/lib/data/services/api/model/login_response/login_response.dart diff --git a/compass_app/model/lib/src/model/auth/login_response/login_response.freezed.dart b/compass_app/app/lib/data/services/api/model/login_response/login_response.freezed.dart similarity index 100% rename from compass_app/model/lib/src/model/auth/login_response/login_response.freezed.dart rename to compass_app/app/lib/data/services/api/model/login_response/login_response.freezed.dart diff --git a/compass_app/model/lib/src/model/auth/login_response/login_response.g.dart b/compass_app/app/lib/data/services/api/model/login_response/login_response.g.dart similarity index 100% rename from compass_app/model/lib/src/model/auth/login_response/login_response.g.dart rename to compass_app/app/lib/data/services/api/model/login_response/login_response.g.dart diff --git a/compass_app/app/lib/data/services/local/local_data_service.dart b/compass_app/app/lib/data/services/local/local_data_service.dart index 0b1a15268..491067d7d 100644 --- a/compass_app/app/lib/data/services/local/local_data_service.dart +++ b/compass_app/app/lib/data/services/local/local_data_service.dart @@ -1,9 +1,11 @@ import 'dart:convert'; -import 'package:compass_model/model.dart'; import 'package:flutter/services.dart'; import '../../../config/assets.dart'; +import '../../../domain/models/activity/activity.dart'; +import '../../../domain/models/continent/continent.dart'; +import '../../../domain/models/destination/destination.dart'; class LocalDataService { List getContinents() { diff --git a/compass_app/app/lib/domain/components/booking/booking_create_component.dart b/compass_app/app/lib/domain/components/booking/booking_create_component.dart index 0acccf0af..9d9690caf 100644 --- a/compass_app/app/lib/domain/components/booking/booking_create_component.dart +++ b/compass_app/app/lib/domain/components/booking/booking_create_component.dart @@ -1,10 +1,13 @@ -import 'package:compass_model/model.dart'; import 'package:logging/logging.dart'; import '../../../data/repositories/activity/activity_repository.dart'; import '../../../data/repositories/booking/booking_repository.dart'; import '../../../data/repositories/destination/destination_repository.dart'; import '../../../utils/result.dart'; +import '../../models/activity/activity.dart'; +import '../../models/booking/booking.dart'; +import '../../models/destination/destination.dart'; +import '../../models/itinerary_config/itinerary_config.dart'; /// Component for creating [Booking] objects from [ItineraryConfig]. /// diff --git a/compass_app/app/lib/domain/components/booking/booking_share_component.dart b/compass_app/app/lib/domain/components/booking/booking_share_component.dart index 89ba1e220..f3fdcd310 100644 --- a/compass_app/app/lib/domain/components/booking/booking_share_component.dart +++ b/compass_app/app/lib/domain/components/booking/booking_share_component.dart @@ -1,10 +1,10 @@ -import 'package:compass_model/model.dart'; import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:share_plus/share_plus.dart'; import '../../../utils/result.dart'; import '../../../ui/core/ui/date_format_start_end.dart'; +import '../../models/booking/booking.dart'; typedef ShareFunction = Future Function(String text); diff --git a/compass_app/model/lib/src/model/activity/activity.dart b/compass_app/app/lib/domain/models/activity/activity.dart similarity index 100% rename from compass_app/model/lib/src/model/activity/activity.dart rename to compass_app/app/lib/domain/models/activity/activity.dart diff --git a/compass_app/model/lib/src/model/activity/activity.freezed.dart b/compass_app/app/lib/domain/models/activity/activity.freezed.dart similarity index 100% rename from compass_app/model/lib/src/model/activity/activity.freezed.dart rename to compass_app/app/lib/domain/models/activity/activity.freezed.dart diff --git a/compass_app/model/lib/src/model/activity/activity.g.dart b/compass_app/app/lib/domain/models/activity/activity.g.dart similarity index 100% rename from compass_app/model/lib/src/model/activity/activity.g.dart rename to compass_app/app/lib/domain/models/activity/activity.g.dart diff --git a/compass_app/model/lib/src/model/booking/booking.dart b/compass_app/app/lib/domain/models/booking/booking.dart similarity index 87% rename from compass_app/model/lib/src/model/booking/booking.dart rename to compass_app/app/lib/domain/models/booking/booking.dart index b03bde055..bed7d45a1 100644 --- a/compass_app/model/lib/src/model/booking/booking.dart +++ b/compass_app/app/lib/domain/models/booking/booking.dart @@ -1,6 +1,8 @@ -import 'package:compass_model/model.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import '../activity/activity.dart'; +import '../destination/destination.dart'; + part 'booking.freezed.dart'; part 'booking.g.dart'; diff --git a/compass_app/model/lib/src/model/booking/booking.freezed.dart b/compass_app/app/lib/domain/models/booking/booking.freezed.dart similarity index 100% rename from compass_app/model/lib/src/model/booking/booking.freezed.dart rename to compass_app/app/lib/domain/models/booking/booking.freezed.dart diff --git a/compass_app/model/lib/src/model/booking/booking.g.dart b/compass_app/app/lib/domain/models/booking/booking.g.dart similarity index 100% rename from compass_app/model/lib/src/model/booking/booking.g.dart rename to compass_app/app/lib/domain/models/booking/booking.g.dart diff --git a/compass_app/model/lib/src/model/continent/continent.dart b/compass_app/app/lib/domain/models/continent/continent.dart similarity index 100% rename from compass_app/model/lib/src/model/continent/continent.dart rename to compass_app/app/lib/domain/models/continent/continent.dart diff --git a/compass_app/model/lib/src/model/continent/continent.freezed.dart b/compass_app/app/lib/domain/models/continent/continent.freezed.dart similarity index 100% rename from compass_app/model/lib/src/model/continent/continent.freezed.dart rename to compass_app/app/lib/domain/models/continent/continent.freezed.dart diff --git a/compass_app/model/lib/src/model/continent/continent.g.dart b/compass_app/app/lib/domain/models/continent/continent.g.dart similarity index 100% rename from compass_app/model/lib/src/model/continent/continent.g.dart rename to compass_app/app/lib/domain/models/continent/continent.g.dart diff --git a/compass_app/model/lib/src/model/destination/destination.dart b/compass_app/app/lib/domain/models/destination/destination.dart similarity index 100% rename from compass_app/model/lib/src/model/destination/destination.dart rename to compass_app/app/lib/domain/models/destination/destination.dart diff --git a/compass_app/model/lib/src/model/destination/destination.freezed.dart b/compass_app/app/lib/domain/models/destination/destination.freezed.dart similarity index 100% rename from compass_app/model/lib/src/model/destination/destination.freezed.dart rename to compass_app/app/lib/domain/models/destination/destination.freezed.dart diff --git a/compass_app/model/lib/src/model/destination/destination.g.dart b/compass_app/app/lib/domain/models/destination/destination.g.dart similarity index 100% rename from compass_app/model/lib/src/model/destination/destination.g.dart rename to compass_app/app/lib/domain/models/destination/destination.g.dart diff --git a/compass_app/model/lib/src/model/itinerary_config/itinerary_config.dart b/compass_app/app/lib/domain/models/itinerary_config/itinerary_config.dart similarity index 100% rename from compass_app/model/lib/src/model/itinerary_config/itinerary_config.dart rename to compass_app/app/lib/domain/models/itinerary_config/itinerary_config.dart diff --git a/compass_app/model/lib/src/model/itinerary_config/itinerary_config.freezed.dart b/compass_app/app/lib/domain/models/itinerary_config/itinerary_config.freezed.dart similarity index 100% rename from compass_app/model/lib/src/model/itinerary_config/itinerary_config.freezed.dart rename to compass_app/app/lib/domain/models/itinerary_config/itinerary_config.freezed.dart diff --git a/compass_app/model/lib/src/model/itinerary_config/itinerary_config.g.dart b/compass_app/app/lib/domain/models/itinerary_config/itinerary_config.g.dart similarity index 100% rename from compass_app/model/lib/src/model/itinerary_config/itinerary_config.g.dart rename to compass_app/app/lib/domain/models/itinerary_config/itinerary_config.g.dart diff --git a/compass_app/app/lib/ui/activities/view_models/activities_viewmodel.dart b/compass_app/app/lib/ui/activities/view_models/activities_viewmodel.dart index 651d23db2..afba6f529 100644 --- a/compass_app/app/lib/ui/activities/view_models/activities_viewmodel.dart +++ b/compass_app/app/lib/ui/activities/view_models/activities_viewmodel.dart @@ -1,9 +1,9 @@ -import 'package:compass_model/model.dart'; import 'package:flutter/foundation.dart'; import 'package:logging/logging.dart'; import '../../../data/repositories/activity/activity_repository.dart'; import '../../../data/repositories/itinerary_config/itinerary_config_repository.dart'; +import '../../../domain/models/activity/activity.dart'; import '../../../utils/command.dart'; import '../../../utils/result.dart'; diff --git a/compass_app/app/lib/ui/activities/widgets/activity_entry.dart b/compass_app/app/lib/ui/activities/widgets/activity_entry.dart index 7bafeb5e5..869662d12 100644 --- a/compass_app/app/lib/ui/activities/widgets/activity_entry.dart +++ b/compass_app/app/lib/ui/activities/widgets/activity_entry.dart @@ -1,7 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter/material.dart'; +import '../../../domain/models/activity/activity.dart'; import '../../../utils/image_error_listener.dart'; import '../../core/ui/custom_checkbox.dart'; diff --git a/compass_app/app/lib/ui/auth/logout/view_models/logout_viewmodel.dart b/compass_app/app/lib/ui/auth/logout/view_models/logout_viewmodel.dart index 1a81ebcd5..ed6882bbc 100644 --- a/compass_app/app/lib/ui/auth/logout/view_models/logout_viewmodel.dart +++ b/compass_app/app/lib/ui/auth/logout/view_models/logout_viewmodel.dart @@ -1,7 +1,6 @@ -import 'package:compass_model/model.dart'; - import '../../../../data/repositories/auth/auth_repository.dart'; import '../../../../data/repositories/itinerary_config/itinerary_config_repository.dart'; +import '../../../../domain/models/itinerary_config/itinerary_config.dart'; import '../../../../utils/command.dart'; import '../../../../utils/result.dart'; diff --git a/compass_app/app/lib/ui/booking/view_models/booking_viewmodel.dart b/compass_app/app/lib/ui/booking/view_models/booking_viewmodel.dart index b6fab19bf..dec9fe03a 100644 --- a/compass_app/app/lib/ui/booking/view_models/booking_viewmodel.dart +++ b/compass_app/app/lib/ui/booking/view_models/booking_viewmodel.dart @@ -1,9 +1,10 @@ -import 'package:compass_model/model.dart'; import 'package:flutter/foundation.dart'; import 'package:logging/logging.dart'; import '../../../data/repositories/booking/booking_repository.dart'; import '../../../data/repositories/itinerary_config/itinerary_config_repository.dart'; +import '../../../domain/models/booking/booking.dart'; +import '../../../domain/models/itinerary_config/itinerary_config.dart'; import '../../../utils/command.dart'; import '../../../utils/result.dart'; import '../../../domain/components/booking/booking_create_component.dart'; diff --git a/compass_app/app/lib/ui/booking/widgets/booking_body.dart b/compass_app/app/lib/ui/booking/widgets/booking_body.dart index 1548956f3..06c03e1e0 100644 --- a/compass_app/app/lib/ui/booking/widgets/booking_body.dart +++ b/compass_app/app/lib/ui/booking/widgets/booking_body.dart @@ -1,7 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter/material.dart'; +import '../../../domain/models/activity/activity.dart'; import '../../../utils/image_error_listener.dart'; import '../../core/themes/dimens.dart'; import '../view_models/booking_viewmodel.dart'; diff --git a/compass_app/app/lib/ui/booking/widgets/booking_header.dart b/compass_app/app/lib/ui/booking/widgets/booking_header.dart index f3b53c088..0be5c4c10 100644 --- a/compass_app/app/lib/ui/booking/widgets/booking_header.dart +++ b/compass_app/app/lib/ui/booking/widgets/booking_header.dart @@ -1,7 +1,7 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter/material.dart'; +import '../../../domain/models/booking/booking.dart'; import '../../../utils/image_error_listener.dart'; import '../../core/localization/applocalization.dart'; import '../../core/themes/colors.dart'; diff --git a/compass_app/app/lib/ui/core/ui/search_bar.dart b/compass_app/app/lib/ui/core/ui/search_bar.dart index b0a2c4aba..ccce95058 100644 --- a/compass_app/app/lib/ui/core/ui/search_bar.dart +++ b/compass_app/app/lib/ui/core/ui/search_bar.dart @@ -1,6 +1,6 @@ -import 'package:compass_model/model.dart'; import 'package:flutter/material.dart'; +import '../../../domain/models/itinerary_config/itinerary_config.dart'; import '../localization/applocalization.dart'; import '../themes/colors.dart'; import '../themes/dimens.dart'; diff --git a/compass_app/app/lib/ui/results/view_models/results_viewmodel.dart b/compass_app/app/lib/ui/results/view_models/results_viewmodel.dart index ece6dd944..cba80429a 100644 --- a/compass_app/app/lib/ui/results/view_models/results_viewmodel.dart +++ b/compass_app/app/lib/ui/results/view_models/results_viewmodel.dart @@ -1,8 +1,9 @@ -import 'package:compass_model/model.dart'; import 'package:logging/logging.dart'; import '../../../data/repositories/destination/destination_repository.dart'; import '../../../data/repositories/itinerary_config/itinerary_config_repository.dart'; +import '../../../domain/models/destination/destination.dart'; +import '../../../domain/models/itinerary_config/itinerary_config.dart'; import '../../../utils/command.dart'; import '../../../utils/result.dart'; import 'package:flutter/cupertino.dart'; diff --git a/compass_app/app/lib/ui/results/widgets/result_card.dart b/compass_app/app/lib/ui/results/widgets/result_card.dart index f4a5f0712..83d8825b7 100644 --- a/compass_app/app/lib/ui/results/widgets/result_card.dart +++ b/compass_app/app/lib/ui/results/widgets/result_card.dart @@ -1,7 +1,6 @@ -import 'package:compass_model/model.dart'; - import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; +import '../../../domain/models/destination/destination.dart'; import '../../../utils/image_error_listener.dart'; import '../../core/themes/text_styles.dart'; import '../../core/ui/tag_chip.dart'; diff --git a/compass_app/app/lib/ui/search_form/view_models/search_form_viewmodel.dart b/compass_app/app/lib/ui/search_form/view_models/search_form_viewmodel.dart index 792b5058e..c3cf787b6 100644 --- a/compass_app/app/lib/ui/search_form/view_models/search_form_viewmodel.dart +++ b/compass_app/app/lib/ui/search_form/view_models/search_form_viewmodel.dart @@ -1,9 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:compass_model/model.dart'; import 'package:logging/logging.dart'; import '../../../data/repositories/continent/continent_repository.dart'; import '../../../data/repositories/itinerary_config/itinerary_config_repository.dart'; +import '../../../domain/models/continent/continent.dart'; +import '../../../domain/models/itinerary_config/itinerary_config.dart'; import '../../../utils/command.dart'; import '../../../utils/result.dart'; diff --git a/compass_app/app/lib/ui/search_form/widgets/search_form_continent.dart b/compass_app/app/lib/ui/search_form/widgets/search_form_continent.dart index d516900a7..d2485f3b1 100644 --- a/compass_app/app/lib/ui/search_form/widgets/search_form_continent.dart +++ b/compass_app/app/lib/ui/search_form/widgets/search_form_continent.dart @@ -1,8 +1,8 @@ import 'package:cached_network_image/cached_network_image.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import '../../../domain/models/continent/continent.dart'; import '../../../utils/image_error_listener.dart'; import '../../core/localization/applocalization.dart'; import '../../core/themes/colors.dart'; diff --git a/compass_app/app/pubspec.yaml b/compass_app/app/pubspec.yaml index e4067fcc5..c2aa37aae 100644 --- a/compass_app/app/pubspec.yaml +++ b/compass_app/app/pubspec.yaml @@ -9,8 +9,6 @@ environment: dependencies: cached_network_image: ^3.3.1 collection: ^1.18.0 - compass_model: - path: ../model flutter: sdk: flutter flutter_localizations: diff --git a/compass_app/app/test/domain/components/booking/booking_create_component_test.dart b/compass_app/app/test/domain/components/booking/booking_create_component_test.dart index e3c6f4f73..3943208c4 100644 --- a/compass_app/app/test/domain/components/booking/booking_create_component_test.dart +++ b/compass_app/app/test/domain/components/booking/booking_create_component_test.dart @@ -1,5 +1,5 @@ import 'package:compass_app/domain/components/booking/booking_create_component.dart'; -import 'package:compass_model/model.dart'; +import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../../../testing/fakes/repositories/fake_activities_repository.dart'; diff --git a/compass_app/app/test/domain/components/booking/booking_share_component_test.dart b/compass_app/app/test/domain/components/booking/booking_share_component_test.dart index 6c884d3e9..f9cff2546 100644 --- a/compass_app/app/test/domain/components/booking/booking_share_component_test.dart +++ b/compass_app/app/test/domain/components/booking/booking_share_component_test.dart @@ -1,5 +1,5 @@ import 'package:compass_app/domain/components/booking/booking_share_component.dart'; -import 'package:compass_model/model.dart'; +import 'package:compass_app/domain/models/booking/booking.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../../../testing/models/activity.dart'; diff --git a/compass_app/app/test/ui/activities/activities_screen_test.dart b/compass_app/app/test/ui/activities/activities_screen_test.dart index ab13b0ef4..d40f1504d 100644 --- a/compass_app/app/test/ui/activities/activities_screen_test.dart +++ b/compass_app/app/test/ui/activities/activities_screen_test.dart @@ -1,7 +1,7 @@ +import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart'; import 'package:compass_app/ui/activities/view_models/activities_viewmodel.dart'; import 'package:compass_app/ui/activities/widgets/activities_screen.dart'; import 'package:compass_app/ui/activities/widgets/activity_entry.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; diff --git a/compass_app/app/test/ui/auth/logout_button_test.dart b/compass_app/app/test/ui/auth/logout_button_test.dart index 832c61aab..ec846dcb7 100644 --- a/compass_app/app/test/ui/auth/logout_button_test.dart +++ b/compass_app/app/test/ui/auth/logout_button_test.dart @@ -1,6 +1,6 @@ +import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart'; import 'package:compass_app/ui/auth/logout/view_models/logout_viewmodel.dart'; import 'package:compass_app/ui/auth/logout/widgets/logout_button.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail_image_network/mocktail_image_network.dart'; diff --git a/compass_app/app/test/ui/booking/booking_screen_test.dart b/compass_app/app/test/ui/booking/booking_screen_test.dart index 1453fb5f9..f96bb3ecf 100644 --- a/compass_app/app/test/ui/booking/booking_screen_test.dart +++ b/compass_app/app/test/ui/booking/booking_screen_test.dart @@ -1,8 +1,8 @@ import 'package:compass_app/domain/components/booking/booking_create_component.dart'; import 'package:compass_app/domain/components/booking/booking_share_component.dart'; +import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart'; import 'package:compass_app/ui/booking/view_models/booking_viewmodel.dart'; import 'package:compass_app/ui/booking/widgets/booking_screen.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/compass_app/app/test/ui/results/results_screen_test.dart b/compass_app/app/test/ui/results/results_screen_test.dart index 8d7390517..66a4df780 100644 --- a/compass_app/app/test/ui/results/results_screen_test.dart +++ b/compass_app/app/test/ui/results/results_screen_test.dart @@ -1,6 +1,6 @@ +import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart'; import 'package:compass_app/ui/results/view_models/results_viewmodel.dart'; import 'package:compass_app/ui/results/widgets/results_screen.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:mocktail_image_network/mocktail_image_network.dart'; diff --git a/compass_app/app/test/ui/results/results_viewmodel_test.dart b/compass_app/app/test/ui/results/results_viewmodel_test.dart index 910a23a4e..dd5b5ee5d 100644 --- a/compass_app/app/test/ui/results/results_viewmodel_test.dart +++ b/compass_app/app/test/ui/results/results_viewmodel_test.dart @@ -1,5 +1,5 @@ +import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart'; import 'package:compass_app/ui/results/view_models/results_viewmodel.dart'; -import 'package:compass_model/model.dart'; import 'package:flutter_test/flutter_test.dart'; import '../../../testing/fakes/repositories/fake_destination_repository.dart'; diff --git a/compass_app/app/testing/fakes/repositories/fake_activities_repository.dart b/compass_app/app/testing/fakes/repositories/fake_activities_repository.dart index 60eae5dbd..1f44a6c66 100644 --- a/compass_app/app/testing/fakes/repositories/fake_activities_repository.dart +++ b/compass_app/app/testing/fakes/repositories/fake_activities_repository.dart @@ -1,6 +1,6 @@ import 'package:compass_app/data/repositories/activity/activity_repository.dart'; +import 'package:compass_app/domain/models/activity/activity.dart'; import 'package:compass_app/utils/result.dart'; -import 'package:compass_model/src/model/activity/activity.dart'; import 'package:flutter/foundation.dart'; import '../../models/activity.dart'; diff --git a/compass_app/app/testing/fakes/repositories/fake_booking_repository.dart b/compass_app/app/testing/fakes/repositories/fake_booking_repository.dart index 543a52df8..aedfed391 100644 --- a/compass_app/app/testing/fakes/repositories/fake_booking_repository.dart +++ b/compass_app/app/testing/fakes/repositories/fake_booking_repository.dart @@ -1,8 +1,8 @@ import 'package:collection/collection.dart'; import 'package:compass_app/data/repositories/booking/booking_repository.dart'; +import 'package:compass_app/domain/models/booking/booking.dart'; import 'package:compass_app/domain/models/booking/booking_summary.dart'; import 'package:compass_app/utils/result.dart'; -import 'package:compass_model/src/model/booking/booking.dart'; class FakeBookingRepository implements BookingRepository { List bookings = List.empty(growable: true); diff --git a/compass_app/app/testing/fakes/repositories/fake_continent_repository.dart b/compass_app/app/testing/fakes/repositories/fake_continent_repository.dart index 1e58c9fe8..5c265aedd 100644 --- a/compass_app/app/testing/fakes/repositories/fake_continent_repository.dart +++ b/compass_app/app/testing/fakes/repositories/fake_continent_repository.dart @@ -1,5 +1,5 @@ -import 'package:compass_model/model.dart'; import 'package:compass_app/data/repositories/continent/continent_repository.dart'; +import 'package:compass_app/domain/models/continent/continent.dart'; import 'package:compass_app/utils/result.dart'; import 'package:flutter/foundation.dart'; diff --git a/compass_app/app/testing/fakes/repositories/fake_destination_repository.dart b/compass_app/app/testing/fakes/repositories/fake_destination_repository.dart index 89de911d2..fa247a47a 100644 --- a/compass_app/app/testing/fakes/repositories/fake_destination_repository.dart +++ b/compass_app/app/testing/fakes/repositories/fake_destination_repository.dart @@ -1,5 +1,5 @@ -import 'package:compass_model/model.dart'; import 'package:compass_app/data/repositories/destination/destination_repository.dart'; +import 'package:compass_app/domain/models/destination/destination.dart'; import 'package:compass_app/utils/result.dart'; import 'package:flutter/foundation.dart'; diff --git a/compass_app/app/testing/fakes/repositories/fake_itinerary_config_repository.dart b/compass_app/app/testing/fakes/repositories/fake_itinerary_config_repository.dart index 54e48d0f6..116efe2d8 100644 --- a/compass_app/app/testing/fakes/repositories/fake_itinerary_config_repository.dart +++ b/compass_app/app/testing/fakes/repositories/fake_itinerary_config_repository.dart @@ -1,6 +1,6 @@ import 'package:compass_app/data/repositories/itinerary_config/itinerary_config_repository.dart'; +import 'package:compass_app/domain/models/itinerary_config/itinerary_config.dart'; import 'package:compass_app/utils/result.dart'; -import 'package:compass_model/src/model/itinerary_config/itinerary_config.dart'; import 'package:flutter/foundation.dart'; class FakeItineraryConfigRepository implements ItineraryConfigRepository { diff --git a/compass_app/app/testing/fakes/services/fake_api_client.dart b/compass_app/app/testing/fakes/services/fake_api_client.dart index 9fe5a8934..4158a3304 100644 --- a/compass_app/app/testing/fakes/services/fake_api_client.dart +++ b/compass_app/app/testing/fakes/services/fake_api_client.dart @@ -1,7 +1,9 @@ import 'package:compass_app/data/services/api/api_client.dart'; import 'package:compass_app/data/services/api/model/booking/booking_api_model.dart'; +import 'package:compass_app/domain/models/activity/activity.dart'; +import 'package:compass_app/domain/models/continent/continent.dart'; +import 'package:compass_app/domain/models/destination/destination.dart'; import 'package:compass_app/utils/result.dart'; -import 'package:compass_model/model.dart'; import '../../models/activity.dart'; import '../../models/booking.dart'; diff --git a/compass_app/app/testing/fakes/services/fake_auth_api_client.dart b/compass_app/app/testing/fakes/services/fake_auth_api_client.dart index 219d80b5a..2ba8e3226 100644 --- a/compass_app/app/testing/fakes/services/fake_auth_api_client.dart +++ b/compass_app/app/testing/fakes/services/fake_auth_api_client.dart @@ -1,7 +1,7 @@ import 'package:compass_app/data/services/api/auth_api_client.dart'; +import 'package:compass_app/data/services/api/model/login_request/login_request.dart'; +import 'package:compass_app/data/services/api/model/login_response/login_response.dart'; import 'package:compass_app/utils/result.dart'; -import 'package:compass_model/src/model/auth/login_request/login_request.dart'; -import 'package:compass_model/src/model/auth/login_response/login_response.dart'; class FakeAuthApiClient implements AuthApiClient { @override diff --git a/compass_app/app/testing/models/activity.dart b/compass_app/app/testing/models/activity.dart index ffb79d8d2..62cf1f918 100644 --- a/compass_app/app/testing/models/activity.dart +++ b/compass_app/app/testing/models/activity.dart @@ -1,4 +1,4 @@ -import 'package:compass_model/model.dart'; +import 'package:compass_app/domain/models/activity/activity.dart'; const kActivity = Activity( description: 'DESCRIPTION', diff --git a/compass_app/app/testing/models/booking.dart b/compass_app/app/testing/models/booking.dart index 0d270ea81..9f72293b1 100644 --- a/compass_app/app/testing/models/booking.dart +++ b/compass_app/app/testing/models/booking.dart @@ -1,6 +1,6 @@ import 'package:compass_app/data/services/api/model/booking/booking_api_model.dart'; +import 'package:compass_app/domain/models/booking/booking.dart'; import 'package:compass_app/domain/models/booking/booking_summary.dart'; -import 'package:compass_model/model.dart'; import 'activity.dart'; import 'destination.dart'; diff --git a/compass_app/app/testing/models/destination.dart b/compass_app/app/testing/models/destination.dart index d8acd676c..9945441f4 100644 --- a/compass_app/app/testing/models/destination.dart +++ b/compass_app/app/testing/models/destination.dart @@ -1,4 +1,4 @@ -import 'package:compass_model/model.dart'; +import 'package:compass_app/domain/models/destination/destination.dart'; const kDestination1 = Destination( ref: 'ref1', diff --git a/compass_app/model/.gitignore b/compass_app/model/.gitignore deleted file mode 100644 index 3cceda557..000000000 --- a/compass_app/model/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# https://dart.dev/guides/libraries/private-files -# Created by `dart pub` -.dart_tool/ - -# Avoid committing pubspec.lock for library packages; see -# https://dart.dev/guides/libraries/private-files#pubspeclock. -pubspec.lock diff --git a/compass_app/model/README.md b/compass_app/model/README.md deleted file mode 100644 index 171296171..000000000 --- a/compass_app/model/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# compass_model - -Shared Data Model for the `compass_app` example. diff --git a/compass_app/model/analysis_options.yaml b/compass_app/model/analysis_options.yaml deleted file mode 100644 index dee8927aa..000000000 --- a/compass_app/model/analysis_options.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/compass_app/model/lib/model.dart b/compass_app/model/lib/model.dart deleted file mode 100644 index 8538e5ccc..000000000 --- a/compass_app/model/lib/model.dart +++ /dev/null @@ -1,9 +0,0 @@ -library; - -export 'src/model/activity/activity.dart'; -export 'src/model/auth/login_request/login_request.dart'; -export 'src/model/auth/login_response/login_response.dart'; -export 'src/model/booking/booking.dart'; -export 'src/model/continent/continent.dart'; -export 'src/model/destination/destination.dart'; -export 'src/model/itinerary_config/itinerary_config.dart'; diff --git a/compass_app/model/pubspec.yaml b/compass_app/model/pubspec.yaml deleted file mode 100644 index da7ee8d11..000000000 --- a/compass_app/model/pubspec.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: compass_model -description: Compass App Data Model -publish_to: 'none' -version: 1.0.0 - -environment: - sdk: ^3.4.3 - -dev_dependencies: - build_runner: ^2.4.11 - freezed: ^2.5.7 - json_serializable: ^6.8.0 - lints: ^3.0.0 - test: ^1.24.0 -dependencies: - freezed_annotation: ^2.4.4 - json_annotation: ^4.9.0 diff --git a/compass_app/model/test/.gitkeep b/compass_app/model/test/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/compass_app/server/lib/config/assets.dart b/compass_app/server/lib/config/assets.dart index b28b45ee2..e0706b5ef 100644 --- a/compass_app/server/lib/config/assets.dart +++ b/compass_app/server/lib/config/assets.dart @@ -1,7 +1,8 @@ import 'dart:convert'; import 'dart:io'; -import 'package:compass_model/model.dart'; +import '../model/activity/activity.dart'; +import '../model/destination/destination.dart'; class Assets { static const _activities = '../app/assets/activities.json'; diff --git a/compass_app/server/lib/model/activity/activity.dart b/compass_app/server/lib/model/activity/activity.dart new file mode 100644 index 000000000..f5d650564 --- /dev/null +++ b/compass_app/server/lib/model/activity/activity.dart @@ -0,0 +1,52 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'activity.freezed.dart'; + +part 'activity.g.dart'; + +enum TimeOfDay { + any, + morning, + afternoon, + evening, + night, +} + +@freezed +class Activity with _$Activity { + const factory Activity({ + /// e.g. 'Glacier Trekking and Ice Climbing' + required String name, + + /// e.g. 'Embark on a thrilling adventure exploring the awe-inspiring glaciers of Alaska. Hike across the icy terrain, marvel at the deep blue crevasses, and even try your hand at ice climbing for an unforgettable experience.' + required String description, + + /// e.g. 'Matanuska Glacier or Mendenhall Glacier' + required String locationName, + + /// Duration in days. + /// e.g. 8 + required int duration, + + /// e.g. 'morning' + required TimeOfDay timeOfDay, + + /// e.g. false + required bool familyFriendly, + + /// e.g. 4 + required int price, + + /// e.g. 'alaska' + required String destinationRef, + + /// e.g. 'glacier-trekking-and-ice-climbing' + required String ref, + + /// e.g. 'https://storage.googleapis.com/tripedia-images/activities/alaska_glacier-trekking-and-ice-climbing.jpg' + required String imageUrl, + }) = _Activity; + + factory Activity.fromJson(Map json) => + _$ActivityFromJson(json); +} diff --git a/compass_app/server/lib/model/activity/activity.freezed.dart b/compass_app/server/lib/model/activity/activity.freezed.dart new file mode 100644 index 000000000..6e277d0bc --- /dev/null +++ b/compass_app/server/lib/model/activity/activity.freezed.dart @@ -0,0 +1,425 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'activity.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Activity _$ActivityFromJson(Map json) { + return _Activity.fromJson(json); +} + +/// @nodoc +mixin _$Activity { + /// e.g. 'Glacier Trekking and Ice Climbing' + String get name => throw _privateConstructorUsedError; + + /// e.g. 'Embark on a thrilling adventure exploring the awe-inspiring glaciers of Alaska. Hike across the icy terrain, marvel at the deep blue crevasses, and even try your hand at ice climbing for an unforgettable experience.' + String get description => throw _privateConstructorUsedError; + + /// e.g. 'Matanuska Glacier or Mendenhall Glacier' + String get locationName => throw _privateConstructorUsedError; + + /// Duration in days. + /// e.g. 8 + int get duration => throw _privateConstructorUsedError; + + /// e.g. 'morning' + TimeOfDay get timeOfDay => throw _privateConstructorUsedError; + + /// e.g. false + bool get familyFriendly => throw _privateConstructorUsedError; + + /// e.g. 4 + int get price => throw _privateConstructorUsedError; + + /// e.g. 'alaska' + String get destinationRef => throw _privateConstructorUsedError; + + /// e.g. 'glacier-trekking-and-ice-climbing' + String get ref => throw _privateConstructorUsedError; + + /// e.g. 'https://storage.googleapis.com/tripedia-images/activities/alaska_glacier-trekking-and-ice-climbing.jpg' + String get imageUrl => throw _privateConstructorUsedError; + + /// Serializes this Activity to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Activity + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ActivityCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ActivityCopyWith<$Res> { + factory $ActivityCopyWith(Activity value, $Res Function(Activity) then) = + _$ActivityCopyWithImpl<$Res, Activity>; + @useResult + $Res call( + {String name, + String description, + String locationName, + int duration, + TimeOfDay timeOfDay, + bool familyFriendly, + int price, + String destinationRef, + String ref, + String imageUrl}); +} + +/// @nodoc +class _$ActivityCopyWithImpl<$Res, $Val extends Activity> + implements $ActivityCopyWith<$Res> { + _$ActivityCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Activity + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? description = null, + Object? locationName = null, + Object? duration = null, + Object? timeOfDay = null, + Object? familyFriendly = null, + Object? price = null, + Object? destinationRef = null, + Object? ref = null, + Object? imageUrl = null, + }) { + return _then(_value.copyWith( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + description: null == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String, + locationName: null == locationName + ? _value.locationName + : locationName // ignore: cast_nullable_to_non_nullable + as String, + duration: null == duration + ? _value.duration + : duration // ignore: cast_nullable_to_non_nullable + as int, + timeOfDay: null == timeOfDay + ? _value.timeOfDay + : timeOfDay // ignore: cast_nullable_to_non_nullable + as TimeOfDay, + familyFriendly: null == familyFriendly + ? _value.familyFriendly + : familyFriendly // ignore: cast_nullable_to_non_nullable + as bool, + price: null == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as int, + destinationRef: null == destinationRef + ? _value.destinationRef + : destinationRef // ignore: cast_nullable_to_non_nullable + as String, + ref: null == ref + ? _value.ref + : ref // ignore: cast_nullable_to_non_nullable + as String, + imageUrl: null == imageUrl + ? _value.imageUrl + : imageUrl // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ActivityImplCopyWith<$Res> + implements $ActivityCopyWith<$Res> { + factory _$$ActivityImplCopyWith( + _$ActivityImpl value, $Res Function(_$ActivityImpl) then) = + __$$ActivityImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String name, + String description, + String locationName, + int duration, + TimeOfDay timeOfDay, + bool familyFriendly, + int price, + String destinationRef, + String ref, + String imageUrl}); +} + +/// @nodoc +class __$$ActivityImplCopyWithImpl<$Res> + extends _$ActivityCopyWithImpl<$Res, _$ActivityImpl> + implements _$$ActivityImplCopyWith<$Res> { + __$$ActivityImplCopyWithImpl( + _$ActivityImpl _value, $Res Function(_$ActivityImpl) _then) + : super(_value, _then); + + /// Create a copy of Activity + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? description = null, + Object? locationName = null, + Object? duration = null, + Object? timeOfDay = null, + Object? familyFriendly = null, + Object? price = null, + Object? destinationRef = null, + Object? ref = null, + Object? imageUrl = null, + }) { + return _then(_$ActivityImpl( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + description: null == description + ? _value.description + : description // ignore: cast_nullable_to_non_nullable + as String, + locationName: null == locationName + ? _value.locationName + : locationName // ignore: cast_nullable_to_non_nullable + as String, + duration: null == duration + ? _value.duration + : duration // ignore: cast_nullable_to_non_nullable + as int, + timeOfDay: null == timeOfDay + ? _value.timeOfDay + : timeOfDay // ignore: cast_nullable_to_non_nullable + as TimeOfDay, + familyFriendly: null == familyFriendly + ? _value.familyFriendly + : familyFriendly // ignore: cast_nullable_to_non_nullable + as bool, + price: null == price + ? _value.price + : price // ignore: cast_nullable_to_non_nullable + as int, + destinationRef: null == destinationRef + ? _value.destinationRef + : destinationRef // ignore: cast_nullable_to_non_nullable + as String, + ref: null == ref + ? _value.ref + : ref // ignore: cast_nullable_to_non_nullable + as String, + imageUrl: null == imageUrl + ? _value.imageUrl + : imageUrl // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ActivityImpl implements _Activity { + const _$ActivityImpl( + {required this.name, + required this.description, + required this.locationName, + required this.duration, + required this.timeOfDay, + required this.familyFriendly, + required this.price, + required this.destinationRef, + required this.ref, + required this.imageUrl}); + + factory _$ActivityImpl.fromJson(Map json) => + _$$ActivityImplFromJson(json); + + /// e.g. 'Glacier Trekking and Ice Climbing' + @override + final String name; + + /// e.g. 'Embark on a thrilling adventure exploring the awe-inspiring glaciers of Alaska. Hike across the icy terrain, marvel at the deep blue crevasses, and even try your hand at ice climbing for an unforgettable experience.' + @override + final String description; + + /// e.g. 'Matanuska Glacier or Mendenhall Glacier' + @override + final String locationName; + + /// Duration in days. + /// e.g. 8 + @override + final int duration; + + /// e.g. 'morning' + @override + final TimeOfDay timeOfDay; + + /// e.g. false + @override + final bool familyFriendly; + + /// e.g. 4 + @override + final int price; + + /// e.g. 'alaska' + @override + final String destinationRef; + + /// e.g. 'glacier-trekking-and-ice-climbing' + @override + final String ref; + + /// e.g. 'https://storage.googleapis.com/tripedia-images/activities/alaska_glacier-trekking-and-ice-climbing.jpg' + @override + final String imageUrl; + + @override + String toString() { + return 'Activity(name: $name, description: $description, locationName: $locationName, duration: $duration, timeOfDay: $timeOfDay, familyFriendly: $familyFriendly, price: $price, destinationRef: $destinationRef, ref: $ref, imageUrl: $imageUrl)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ActivityImpl && + (identical(other.name, name) || other.name == name) && + (identical(other.description, description) || + other.description == description) && + (identical(other.locationName, locationName) || + other.locationName == locationName) && + (identical(other.duration, duration) || + other.duration == duration) && + (identical(other.timeOfDay, timeOfDay) || + other.timeOfDay == timeOfDay) && + (identical(other.familyFriendly, familyFriendly) || + other.familyFriendly == familyFriendly) && + (identical(other.price, price) || other.price == price) && + (identical(other.destinationRef, destinationRef) || + other.destinationRef == destinationRef) && + (identical(other.ref, ref) || other.ref == ref) && + (identical(other.imageUrl, imageUrl) || + other.imageUrl == imageUrl)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + name, + description, + locationName, + duration, + timeOfDay, + familyFriendly, + price, + destinationRef, + ref, + imageUrl); + + /// Create a copy of Activity + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ActivityImplCopyWith<_$ActivityImpl> get copyWith => + __$$ActivityImplCopyWithImpl<_$ActivityImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ActivityImplToJson( + this, + ); + } +} + +abstract class _Activity implements Activity { + const factory _Activity( + {required final String name, + required final String description, + required final String locationName, + required final int duration, + required final TimeOfDay timeOfDay, + required final bool familyFriendly, + required final int price, + required final String destinationRef, + required final String ref, + required final String imageUrl}) = _$ActivityImpl; + + factory _Activity.fromJson(Map json) = + _$ActivityImpl.fromJson; + + /// e.g. 'Glacier Trekking and Ice Climbing' + @override + String get name; + + /// e.g. 'Embark on a thrilling adventure exploring the awe-inspiring glaciers of Alaska. Hike across the icy terrain, marvel at the deep blue crevasses, and even try your hand at ice climbing for an unforgettable experience.' + @override + String get description; + + /// e.g. 'Matanuska Glacier or Mendenhall Glacier' + @override + String get locationName; + + /// Duration in days. + /// e.g. 8 + @override + int get duration; + + /// e.g. 'morning' + @override + TimeOfDay get timeOfDay; + + /// e.g. false + @override + bool get familyFriendly; + + /// e.g. 4 + @override + int get price; + + /// e.g. 'alaska' + @override + String get destinationRef; + + /// e.g. 'glacier-trekking-and-ice-climbing' + @override + String get ref; + + /// e.g. 'https://storage.googleapis.com/tripedia-images/activities/alaska_glacier-trekking-and-ice-climbing.jpg' + @override + String get imageUrl; + + /// Create a copy of Activity + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ActivityImplCopyWith<_$ActivityImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/compass_app/server/lib/model/activity/activity.g.dart b/compass_app/server/lib/model/activity/activity.g.dart new file mode 100644 index 000000000..8ad67d674 --- /dev/null +++ b/compass_app/server/lib/model/activity/activity.g.dart @@ -0,0 +1,43 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'activity.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ActivityImpl _$$ActivityImplFromJson(Map json) => + _$ActivityImpl( + name: json['name'] as String, + description: json['description'] as String, + locationName: json['locationName'] as String, + duration: (json['duration'] as num).toInt(), + timeOfDay: $enumDecode(_$TimeOfDayEnumMap, json['timeOfDay']), + familyFriendly: json['familyFriendly'] as bool, + price: (json['price'] as num).toInt(), + destinationRef: json['destinationRef'] as String, + ref: json['ref'] as String, + imageUrl: json['imageUrl'] as String, + ); + +Map _$$ActivityImplToJson(_$ActivityImpl instance) => + { + 'name': instance.name, + 'description': instance.description, + 'locationName': instance.locationName, + 'duration': instance.duration, + 'timeOfDay': _$TimeOfDayEnumMap[instance.timeOfDay]!, + 'familyFriendly': instance.familyFriendly, + 'price': instance.price, + 'destinationRef': instance.destinationRef, + 'ref': instance.ref, + 'imageUrl': instance.imageUrl, + }; + +const _$TimeOfDayEnumMap = { + TimeOfDay.any: 'any', + TimeOfDay.morning: 'morning', + TimeOfDay.afternoon: 'afternoon', + TimeOfDay.evening: 'evening', + TimeOfDay.night: 'night', +}; diff --git a/compass_app/server/lib/model/continent/continent.dart b/compass_app/server/lib/model/continent/continent.dart new file mode 100644 index 000000000..a07a2d4d9 --- /dev/null +++ b/compass_app/server/lib/model/continent/continent.dart @@ -0,0 +1,19 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'continent.freezed.dart'; + +part 'continent.g.dart'; + +@freezed +class Continent with _$Continent { + const factory Continent({ + /// e.g. 'Europe' + required String name, + + /// e.g. 'https://rstr.in/google/tripedia/TmR12QdlVTT' + required String imageUrl, + }) = _Continent; + + factory Continent.fromJson(Map json) => + _$ContinentFromJson(json); +} diff --git a/compass_app/server/lib/model/continent/continent.freezed.dart b/compass_app/server/lib/model/continent/continent.freezed.dart new file mode 100644 index 000000000..f69d01046 --- /dev/null +++ b/compass_app/server/lib/model/continent/continent.freezed.dart @@ -0,0 +1,191 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'continent.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Continent _$ContinentFromJson(Map json) { + return _Continent.fromJson(json); +} + +/// @nodoc +mixin _$Continent { + /// e.g. 'Europe' + String get name => throw _privateConstructorUsedError; + + /// e.g. 'https://rstr.in/google/tripedia/TmR12QdlVTT' + String get imageUrl => throw _privateConstructorUsedError; + + /// Serializes this Continent to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Continent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $ContinentCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $ContinentCopyWith<$Res> { + factory $ContinentCopyWith(Continent value, $Res Function(Continent) then) = + _$ContinentCopyWithImpl<$Res, Continent>; + @useResult + $Res call({String name, String imageUrl}); +} + +/// @nodoc +class _$ContinentCopyWithImpl<$Res, $Val extends Continent> + implements $ContinentCopyWith<$Res> { + _$ContinentCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Continent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? imageUrl = null, + }) { + return _then(_value.copyWith( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + imageUrl: null == imageUrl + ? _value.imageUrl + : imageUrl // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$ContinentImplCopyWith<$Res> + implements $ContinentCopyWith<$Res> { + factory _$$ContinentImplCopyWith( + _$ContinentImpl value, $Res Function(_$ContinentImpl) then) = + __$$ContinentImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String name, String imageUrl}); +} + +/// @nodoc +class __$$ContinentImplCopyWithImpl<$Res> + extends _$ContinentCopyWithImpl<$Res, _$ContinentImpl> + implements _$$ContinentImplCopyWith<$Res> { + __$$ContinentImplCopyWithImpl( + _$ContinentImpl _value, $Res Function(_$ContinentImpl) _then) + : super(_value, _then); + + /// Create a copy of Continent + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? name = null, + Object? imageUrl = null, + }) { + return _then(_$ContinentImpl( + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + imageUrl: null == imageUrl + ? _value.imageUrl + : imageUrl // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$ContinentImpl implements _Continent { + const _$ContinentImpl({required this.name, required this.imageUrl}); + + factory _$ContinentImpl.fromJson(Map json) => + _$$ContinentImplFromJson(json); + + /// e.g. 'Europe' + @override + final String name; + + /// e.g. 'https://rstr.in/google/tripedia/TmR12QdlVTT' + @override + final String imageUrl; + + @override + String toString() { + return 'Continent(name: $name, imageUrl: $imageUrl)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$ContinentImpl && + (identical(other.name, name) || other.name == name) && + (identical(other.imageUrl, imageUrl) || + other.imageUrl == imageUrl)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, name, imageUrl); + + /// Create a copy of Continent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$ContinentImplCopyWith<_$ContinentImpl> get copyWith => + __$$ContinentImplCopyWithImpl<_$ContinentImpl>(this, _$identity); + + @override + Map toJson() { + return _$$ContinentImplToJson( + this, + ); + } +} + +abstract class _Continent implements Continent { + const factory _Continent( + {required final String name, + required final String imageUrl}) = _$ContinentImpl; + + factory _Continent.fromJson(Map json) = + _$ContinentImpl.fromJson; + + /// e.g. 'Europe' + @override + String get name; + + /// e.g. 'https://rstr.in/google/tripedia/TmR12QdlVTT' + @override + String get imageUrl; + + /// Create a copy of Continent + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$ContinentImplCopyWith<_$ContinentImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/compass_app/server/lib/model/continent/continent.g.dart b/compass_app/server/lib/model/continent/continent.g.dart new file mode 100644 index 000000000..41aba78b6 --- /dev/null +++ b/compass_app/server/lib/model/continent/continent.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'continent.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$ContinentImpl _$$ContinentImplFromJson(Map json) => + _$ContinentImpl( + name: json['name'] as String, + imageUrl: json['imageUrl'] as String, + ); + +Map _$$ContinentImplToJson(_$ContinentImpl instance) => + { + 'name': instance.name, + 'imageUrl': instance.imageUrl, + }; diff --git a/compass_app/server/lib/model/destination/destination.dart b/compass_app/server/lib/model/destination/destination.dart new file mode 100644 index 000000000..62bfcd0ee --- /dev/null +++ b/compass_app/server/lib/model/destination/destination.dart @@ -0,0 +1,34 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'destination.freezed.dart'; + +part 'destination.g.dart'; + +@freezed +class Destination with _$Destination { + const factory Destination({ + /// e.g. 'alaska' + required String ref, + + /// e.g. 'Alaska' + required String name, + + /// e.g. 'United States' + required String country, + + /// e.g. 'North America' + required String continent, + + /// e.g. 'Alaska is a haven for outdoor enthusiasts ...' + required String knownFor, + + /// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching'] + required List tags, + + /// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg' + required String imageUrl, + }) = _Destination; + + factory Destination.fromJson(Map json) => + _$DestinationFromJson(json); +} diff --git a/compass_app/server/lib/model/destination/destination.freezed.dart b/compass_app/server/lib/model/destination/destination.freezed.dart new file mode 100644 index 000000000..faaec5902 --- /dev/null +++ b/compass_app/server/lib/model/destination/destination.freezed.dart @@ -0,0 +1,339 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'destination.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +Destination _$DestinationFromJson(Map json) { + return _Destination.fromJson(json); +} + +/// @nodoc +mixin _$Destination { + /// e.g. 'alaska' + String get ref => throw _privateConstructorUsedError; + + /// e.g. 'Alaska' + String get name => throw _privateConstructorUsedError; + + /// e.g. 'United States' + String get country => throw _privateConstructorUsedError; + + /// e.g. 'North America' + String get continent => throw _privateConstructorUsedError; + + /// e.g. 'Alaska is a haven for outdoor enthusiasts ...' + String get knownFor => throw _privateConstructorUsedError; + + /// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching'] + List get tags => throw _privateConstructorUsedError; + + /// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg' + String get imageUrl => throw _privateConstructorUsedError; + + /// Serializes this Destination to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of Destination + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $DestinationCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $DestinationCopyWith<$Res> { + factory $DestinationCopyWith( + Destination value, $Res Function(Destination) then) = + _$DestinationCopyWithImpl<$Res, Destination>; + @useResult + $Res call( + {String ref, + String name, + String country, + String continent, + String knownFor, + List tags, + String imageUrl}); +} + +/// @nodoc +class _$DestinationCopyWithImpl<$Res, $Val extends Destination> + implements $DestinationCopyWith<$Res> { + _$DestinationCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of Destination + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ref = null, + Object? name = null, + Object? country = null, + Object? continent = null, + Object? knownFor = null, + Object? tags = null, + Object? imageUrl = null, + }) { + return _then(_value.copyWith( + ref: null == ref + ? _value.ref + : ref // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + country: null == country + ? _value.country + : country // ignore: cast_nullable_to_non_nullable + as String, + continent: null == continent + ? _value.continent + : continent // ignore: cast_nullable_to_non_nullable + as String, + knownFor: null == knownFor + ? _value.knownFor + : knownFor // ignore: cast_nullable_to_non_nullable + as String, + tags: null == tags + ? _value.tags + : tags // ignore: cast_nullable_to_non_nullable + as List, + imageUrl: null == imageUrl + ? _value.imageUrl + : imageUrl // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$DestinationImplCopyWith<$Res> + implements $DestinationCopyWith<$Res> { + factory _$$DestinationImplCopyWith( + _$DestinationImpl value, $Res Function(_$DestinationImpl) then) = + __$$DestinationImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String ref, + String name, + String country, + String continent, + String knownFor, + List tags, + String imageUrl}); +} + +/// @nodoc +class __$$DestinationImplCopyWithImpl<$Res> + extends _$DestinationCopyWithImpl<$Res, _$DestinationImpl> + implements _$$DestinationImplCopyWith<$Res> { + __$$DestinationImplCopyWithImpl( + _$DestinationImpl _value, $Res Function(_$DestinationImpl) _then) + : super(_value, _then); + + /// Create a copy of Destination + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? ref = null, + Object? name = null, + Object? country = null, + Object? continent = null, + Object? knownFor = null, + Object? tags = null, + Object? imageUrl = null, + }) { + return _then(_$DestinationImpl( + ref: null == ref + ? _value.ref + : ref // ignore: cast_nullable_to_non_nullable + as String, + name: null == name + ? _value.name + : name // ignore: cast_nullable_to_non_nullable + as String, + country: null == country + ? _value.country + : country // ignore: cast_nullable_to_non_nullable + as String, + continent: null == continent + ? _value.continent + : continent // ignore: cast_nullable_to_non_nullable + as String, + knownFor: null == knownFor + ? _value.knownFor + : knownFor // ignore: cast_nullable_to_non_nullable + as String, + tags: null == tags + ? _value._tags + : tags // ignore: cast_nullable_to_non_nullable + as List, + imageUrl: null == imageUrl + ? _value.imageUrl + : imageUrl // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$DestinationImpl implements _Destination { + const _$DestinationImpl( + {required this.ref, + required this.name, + required this.country, + required this.continent, + required this.knownFor, + required final List tags, + required this.imageUrl}) + : _tags = tags; + + factory _$DestinationImpl.fromJson(Map json) => + _$$DestinationImplFromJson(json); + + /// e.g. 'alaska' + @override + final String ref; + + /// e.g. 'Alaska' + @override + final String name; + + /// e.g. 'United States' + @override + final String country; + + /// e.g. 'North America' + @override + final String continent; + + /// e.g. 'Alaska is a haven for outdoor enthusiasts ...' + @override + final String knownFor; + + /// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching'] + final List _tags; + + /// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching'] + @override + List get tags { + if (_tags is EqualUnmodifiableListView) return _tags; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_tags); + } + + /// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg' + @override + final String imageUrl; + + @override + String toString() { + return 'Destination(ref: $ref, name: $name, country: $country, continent: $continent, knownFor: $knownFor, tags: $tags, imageUrl: $imageUrl)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$DestinationImpl && + (identical(other.ref, ref) || other.ref == ref) && + (identical(other.name, name) || other.name == name) && + (identical(other.country, country) || other.country == country) && + (identical(other.continent, continent) || + other.continent == continent) && + (identical(other.knownFor, knownFor) || + other.knownFor == knownFor) && + const DeepCollectionEquality().equals(other._tags, _tags) && + (identical(other.imageUrl, imageUrl) || + other.imageUrl == imageUrl)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, ref, name, country, continent, + knownFor, const DeepCollectionEquality().hash(_tags), imageUrl); + + /// Create a copy of Destination + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$DestinationImplCopyWith<_$DestinationImpl> get copyWith => + __$$DestinationImplCopyWithImpl<_$DestinationImpl>(this, _$identity); + + @override + Map toJson() { + return _$$DestinationImplToJson( + this, + ); + } +} + +abstract class _Destination implements Destination { + const factory _Destination( + {required final String ref, + required final String name, + required final String country, + required final String continent, + required final String knownFor, + required final List tags, + required final String imageUrl}) = _$DestinationImpl; + + factory _Destination.fromJson(Map json) = + _$DestinationImpl.fromJson; + + /// e.g. 'alaska' + @override + String get ref; + + /// e.g. 'Alaska' + @override + String get name; + + /// e.g. 'United States' + @override + String get country; + + /// e.g. 'North America' + @override + String get continent; + + /// e.g. 'Alaska is a haven for outdoor enthusiasts ...' + @override + String get knownFor; + + /// e.g. ['Mountain', 'Off-the-beaten-path', 'Wildlife watching'] + @override + List get tags; + + /// e.g. 'https://storage.googleapis.com/tripedia-images/destinations/alaska.jpg' + @override + String get imageUrl; + + /// Create a copy of Destination + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$DestinationImplCopyWith<_$DestinationImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/compass_app/server/lib/model/destination/destination.g.dart b/compass_app/server/lib/model/destination/destination.g.dart new file mode 100644 index 000000000..796e2bbbd --- /dev/null +++ b/compass_app/server/lib/model/destination/destination.g.dart @@ -0,0 +1,29 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'destination.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$DestinationImpl _$$DestinationImplFromJson(Map json) => + _$DestinationImpl( + ref: json['ref'] as String, + name: json['name'] as String, + country: json['country'] as String, + continent: json['continent'] as String, + knownFor: json['knownFor'] as String, + tags: (json['tags'] as List).map((e) => e as String).toList(), + imageUrl: json['imageUrl'] as String, + ); + +Map _$$DestinationImplToJson(_$DestinationImpl instance) => + { + 'ref': instance.ref, + 'name': instance.name, + 'country': instance.country, + 'continent': instance.continent, + 'knownFor': instance.knownFor, + 'tags': instance.tags, + 'imageUrl': instance.imageUrl, + }; diff --git a/compass_app/server/lib/model/login_request/login_request.dart b/compass_app/server/lib/model/login_request/login_request.dart new file mode 100644 index 000000000..b154a0c75 --- /dev/null +++ b/compass_app/server/lib/model/login_request/login_request.dart @@ -0,0 +1,20 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'login_request.freezed.dart'; + +part 'login_request.g.dart'; + +/// Simple data class to hold login request data. +@freezed +class LoginRequest with _$LoginRequest { + const factory LoginRequest({ + /// Email address. + required String email, + + /// Plain text password. + required String password, + }) = _LoginRequest; + + factory LoginRequest.fromJson(Map json) => + _$LoginRequestFromJson(json); +} diff --git a/compass_app/server/lib/model/login_request/login_request.freezed.dart b/compass_app/server/lib/model/login_request/login_request.freezed.dart new file mode 100644 index 000000000..d130b9a4f --- /dev/null +++ b/compass_app/server/lib/model/login_request/login_request.freezed.dart @@ -0,0 +1,192 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'login_request.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +LoginRequest _$LoginRequestFromJson(Map json) { + return _LoginRequest.fromJson(json); +} + +/// @nodoc +mixin _$LoginRequest { + /// Email address. + String get email => throw _privateConstructorUsedError; + + /// Plain text password. + String get password => throw _privateConstructorUsedError; + + /// Serializes this LoginRequest to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of LoginRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $LoginRequestCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LoginRequestCopyWith<$Res> { + factory $LoginRequestCopyWith( + LoginRequest value, $Res Function(LoginRequest) then) = + _$LoginRequestCopyWithImpl<$Res, LoginRequest>; + @useResult + $Res call({String email, String password}); +} + +/// @nodoc +class _$LoginRequestCopyWithImpl<$Res, $Val extends LoginRequest> + implements $LoginRequestCopyWith<$Res> { + _$LoginRequestCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of LoginRequest + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + Object? password = null, + }) { + return _then(_value.copyWith( + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + password: null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$LoginRequestImplCopyWith<$Res> + implements $LoginRequestCopyWith<$Res> { + factory _$$LoginRequestImplCopyWith( + _$LoginRequestImpl value, $Res Function(_$LoginRequestImpl) then) = + __$$LoginRequestImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String email, String password}); +} + +/// @nodoc +class __$$LoginRequestImplCopyWithImpl<$Res> + extends _$LoginRequestCopyWithImpl<$Res, _$LoginRequestImpl> + implements _$$LoginRequestImplCopyWith<$Res> { + __$$LoginRequestImplCopyWithImpl( + _$LoginRequestImpl _value, $Res Function(_$LoginRequestImpl) _then) + : super(_value, _then); + + /// Create a copy of LoginRequest + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? email = null, + Object? password = null, + }) { + return _then(_$LoginRequestImpl( + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + password: null == password + ? _value.password + : password // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$LoginRequestImpl implements _LoginRequest { + const _$LoginRequestImpl({required this.email, required this.password}); + + factory _$LoginRequestImpl.fromJson(Map json) => + _$$LoginRequestImplFromJson(json); + + /// Email address. + @override + final String email; + + /// Plain text password. + @override + final String password; + + @override + String toString() { + return 'LoginRequest(email: $email, password: $password)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LoginRequestImpl && + (identical(other.email, email) || other.email == email) && + (identical(other.password, password) || + other.password == password)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, email, password); + + /// Create a copy of LoginRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$LoginRequestImplCopyWith<_$LoginRequestImpl> get copyWith => + __$$LoginRequestImplCopyWithImpl<_$LoginRequestImpl>(this, _$identity); + + @override + Map toJson() { + return _$$LoginRequestImplToJson( + this, + ); + } +} + +abstract class _LoginRequest implements LoginRequest { + const factory _LoginRequest( + {required final String email, + required final String password}) = _$LoginRequestImpl; + + factory _LoginRequest.fromJson(Map json) = + _$LoginRequestImpl.fromJson; + + /// Email address. + @override + String get email; + + /// Plain text password. + @override + String get password; + + /// Create a copy of LoginRequest + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$LoginRequestImplCopyWith<_$LoginRequestImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/compass_app/server/lib/model/login_request/login_request.g.dart b/compass_app/server/lib/model/login_request/login_request.g.dart new file mode 100644 index 000000000..0a11bd9f2 --- /dev/null +++ b/compass_app/server/lib/model/login_request/login_request.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'login_request.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$LoginRequestImpl _$$LoginRequestImplFromJson(Map json) => + _$LoginRequestImpl( + email: json['email'] as String, + password: json['password'] as String, + ); + +Map _$$LoginRequestImplToJson(_$LoginRequestImpl instance) => + { + 'email': instance.email, + 'password': instance.password, + }; diff --git a/compass_app/server/lib/model/login_response/login_response.dart b/compass_app/server/lib/model/login_response/login_response.dart new file mode 100644 index 000000000..d7388a894 --- /dev/null +++ b/compass_app/server/lib/model/login_response/login_response.dart @@ -0,0 +1,20 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'login_response.freezed.dart'; + +part 'login_response.g.dart'; + +/// LoginResponse model. +@freezed +class LoginResponse with _$LoginResponse { + const factory LoginResponse({ + /// The token to be used for authentication. + required String token, + + /// The user id. + required String userId, + }) = _LoginResponse; + + factory LoginResponse.fromJson(Map json) => + _$LoginResponseFromJson(json); +} diff --git a/compass_app/server/lib/model/login_response/login_response.freezed.dart b/compass_app/server/lib/model/login_response/login_response.freezed.dart new file mode 100644 index 000000000..bfc5829a6 --- /dev/null +++ b/compass_app/server/lib/model/login_response/login_response.freezed.dart @@ -0,0 +1,191 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'login_response.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +LoginResponse _$LoginResponseFromJson(Map json) { + return _LoginResponse.fromJson(json); +} + +/// @nodoc +mixin _$LoginResponse { + /// The token to be used for authentication. + String get token => throw _privateConstructorUsedError; + + /// The user id. + String get userId => throw _privateConstructorUsedError; + + /// Serializes this LoginResponse to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of LoginResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $LoginResponseCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LoginResponseCopyWith<$Res> { + factory $LoginResponseCopyWith( + LoginResponse value, $Res Function(LoginResponse) then) = + _$LoginResponseCopyWithImpl<$Res, LoginResponse>; + @useResult + $Res call({String token, String userId}); +} + +/// @nodoc +class _$LoginResponseCopyWithImpl<$Res, $Val extends LoginResponse> + implements $LoginResponseCopyWith<$Res> { + _$LoginResponseCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of LoginResponse + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? token = null, + Object? userId = null, + }) { + return _then(_value.copyWith( + token: null == token + ? _value.token + : token // ignore: cast_nullable_to_non_nullable + as String, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$LoginResponseImplCopyWith<$Res> + implements $LoginResponseCopyWith<$Res> { + factory _$$LoginResponseImplCopyWith( + _$LoginResponseImpl value, $Res Function(_$LoginResponseImpl) then) = + __$$LoginResponseImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({String token, String userId}); +} + +/// @nodoc +class __$$LoginResponseImplCopyWithImpl<$Res> + extends _$LoginResponseCopyWithImpl<$Res, _$LoginResponseImpl> + implements _$$LoginResponseImplCopyWith<$Res> { + __$$LoginResponseImplCopyWithImpl( + _$LoginResponseImpl _value, $Res Function(_$LoginResponseImpl) _then) + : super(_value, _then); + + /// Create a copy of LoginResponse + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? token = null, + Object? userId = null, + }) { + return _then(_$LoginResponseImpl( + token: null == token + ? _value.token + : token // ignore: cast_nullable_to_non_nullable + as String, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as String, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$LoginResponseImpl implements _LoginResponse { + const _$LoginResponseImpl({required this.token, required this.userId}); + + factory _$LoginResponseImpl.fromJson(Map json) => + _$$LoginResponseImplFromJson(json); + + /// The token to be used for authentication. + @override + final String token; + + /// The user id. + @override + final String userId; + + @override + String toString() { + return 'LoginResponse(token: $token, userId: $userId)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$LoginResponseImpl && + (identical(other.token, token) || other.token == token) && + (identical(other.userId, userId) || other.userId == userId)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash(runtimeType, token, userId); + + /// Create a copy of LoginResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$LoginResponseImplCopyWith<_$LoginResponseImpl> get copyWith => + __$$LoginResponseImplCopyWithImpl<_$LoginResponseImpl>(this, _$identity); + + @override + Map toJson() { + return _$$LoginResponseImplToJson( + this, + ); + } +} + +abstract class _LoginResponse implements LoginResponse { + const factory _LoginResponse( + {required final String token, + required final String userId}) = _$LoginResponseImpl; + + factory _LoginResponse.fromJson(Map json) = + _$LoginResponseImpl.fromJson; + + /// The token to be used for authentication. + @override + String get token; + + /// The user id. + @override + String get userId; + + /// Create a copy of LoginResponse + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$LoginResponseImplCopyWith<_$LoginResponseImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/compass_app/server/lib/model/login_response/login_response.g.dart b/compass_app/server/lib/model/login_response/login_response.g.dart new file mode 100644 index 000000000..f1ee1db63 --- /dev/null +++ b/compass_app/server/lib/model/login_response/login_response.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'login_response.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$LoginResponseImpl _$$LoginResponseImplFromJson(Map json) => + _$LoginResponseImpl( + token: json['token'] as String, + userId: json['userId'] as String, + ); + +Map _$$LoginResponseImplToJson(_$LoginResponseImpl instance) => + { + 'token': instance.token, + 'userId': instance.userId, + }; diff --git a/compass_app/server/lib/routes/continent.dart b/compass_app/server/lib/routes/continent.dart index 8ca75bc57..dde3ae1b6 100644 --- a/compass_app/server/lib/routes/continent.dart +++ b/compass_app/server/lib/routes/continent.dart @@ -1,7 +1,8 @@ import 'dart:convert'; import 'package:shelf/shelf.dart'; -import 'package:compass_model/model.dart'; + +import '../model/continent/continent.dart'; final _continents = [ Continent( diff --git a/compass_app/server/lib/routes/login.dart b/compass_app/server/lib/routes/login.dart index 28067f334..87472f8ed 100644 --- a/compass_app/server/lib/routes/login.dart +++ b/compass_app/server/lib/routes/login.dart @@ -1,10 +1,12 @@ import 'dart:convert'; -import 'package:compass_model/model.dart'; import 'package:compass_server/config/constants.dart'; import 'package:shelf/shelf.dart'; import 'package:shelf_router/shelf_router.dart'; +import '../model/login_request/login_request.dart'; +import '../model/login_response/login_response.dart'; + /// Implements a simple login API. /// /// This is provided as an example for Flutter architectural purposes only diff --git a/compass_app/server/pubspec.yaml b/compass_app/server/pubspec.yaml index 6a720bb83..5c01dbbae 100644 --- a/compass_app/server/pubspec.yaml +++ b/compass_app/server/pubspec.yaml @@ -12,8 +12,6 @@ dependencies: shelf_router: ^1.1.0 freezed_annotation: ^2.4.4 json_annotation: ^4.9.0 - compass_model: - path: ../model dev_dependencies: http: ^1.1.0 diff --git a/compass_app/server/test/server_test.dart b/compass_app/server/test/server_test.dart index ebd0edc0f..d2d4d9090 100644 --- a/compass_app/server/test/server_test.dart +++ b/compass_app/server/test/server_test.dart @@ -2,9 +2,13 @@ import 'dart:convert'; import 'dart:io'; // TODO: Remove the compass_model and replace by a server-side model -import 'package:compass_model/model.dart' hide Booking; import 'package:compass_server/config/constants.dart'; +import 'package:compass_server/model/activity/activity.dart'; import 'package:compass_server/model/booking/booking.dart'; +import 'package:compass_server/model/continent/continent.dart'; +import 'package:compass_server/model/destination/destination.dart'; +import 'package:compass_server/model/login_request/login_request.dart'; +import 'package:compass_server/model/login_response/login_response.dart'; import 'package:http/http.dart'; import 'package:test/test.dart';