StanfordSpezi / SpeziAccount

The Spezi Account module to enable login and signup functionality
https://swiftpackageindex.com/StanfordSpezi/SpeziAccount/documentation/
MIT License
5 stars 5 forks source link

Model `Account` and `AccountService` as Spezi Module #60

Closed Supereg closed 1 month ago

Supereg commented 3 months ago

Model Account and AccountService as Spezi Module

:recycle: Current situation & Problem

The Account model and AccountServices were introduced before Spezi had sophisticated support for Modules. Therefore, SpeziAccount provides infrastructure like the @AccountReference to access the Account model from certain places like an Account Service or from a Standard that conforms to a SpeziAccount constraint. Other than that, the Account model can only be accessed from within the SwiftUI view hierarchy. This design is generally relatively inflexible and one has to find workarounds to (a) access Account from a Spezi Module and (b) access Spezi Modules from within an AccountService. Typically this involves nesting Account Services into basically empty Spezi Modules or injecting ViewModifiers into the global SwiftUI view hierarchy to get access to the Account.

This PR addresses the problem by making Account and AccountServices Spezi Modules that can be used with all Spezi infrastructure like the @Dependency property wrapper. This greatly improves flexibility when developing with SpeziAccount.

:gear: Release Notes

:books: Documentation

TBA

:white_check_mark: Testing

--

:pencil: Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 38.33333% with 74 lines in your changes missing coverage. Please review.

Project coverage is 73.12%. Comparing base (2de0720) to head (66d71c1). Report is 1 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60/graphs/tree.svg?width=650&height=150&src=pr&token=AudNwGU7tR&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi)](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ```diff @@ Coverage Diff @@ ## main #60 +/- ## ========================================== - Coverage 76.12% 73.12% -3.00% ========================================== Files 116 115 -1 Lines 4020 4065 +45 ========================================== - Hits 3060 2972 -88 - Misses 960 1093 +133 ``` | [Files](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) | Coverage Δ | | |---|---|---| | [Sources/SpeziAccount/AccountHeader.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountHeader.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudEhlYWRlci5zd2lmdA==) | `0.00% <ø> (ø)` | | | [...s/SpeziAccount/AccountService/AccountService.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountService%2FAccountService.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFNlcnZpY2UvQWNjb3VudFNlcnZpY2Uuc3dpZnQ=) | `80.00% <ø> (ø)` | | | [...Account/AccountService/AccountServiceBuilder.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountService%2FAccountServiceBuilder.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFNlcnZpY2UvQWNjb3VudFNlcnZpY2VCdWlsZGVyLnN3aWZ0) | `100.00% <100.00%> (+100.00%)` | :arrow_up: | | [...e/Wrapper/NotifyStandardBackedAccountService.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountService%2FWrapper%2FNotifyStandardBackedAccountService.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFNlcnZpY2UvV3JhcHBlci9Ob3RpZnlTdGFuZGFyZEJhY2tlZEFjY291bnRTZXJ2aWNlLnN3aWZ0) | `100.00% <ø> (ø)` | | | [...ccount/AccountService/Wrapper/StandardBacked.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountService%2FWrapper%2FStandardBacked.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFNlcnZpY2UvV3JhcHBlci9TdGFuZGFyZEJhY2tlZC5zd2lmdA==) | `93.62% <100.00%> (ø)` | | | [.../Wrapper/StorageStandardBackedAccountService.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountService%2FWrapper%2FStorageStandardBackedAccountService.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFNlcnZpY2UvV3JhcHBlci9TdG9yYWdlU3RhbmRhcmRCYWNrZWRBY2NvdW50U2VydmljZS5zd2lmdA==) | `96.30% <ø> (+0.05%)` | :arrow_up: | | [...peziAccount/Mock/MockSignInWithAppleProvider.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FMock%2FMockSignInWithAppleProvider.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvTW9jay9Nb2NrU2lnbkluV2l0aEFwcGxlUHJvdmlkZXIuc3dpZnQ=) | `44.83% <ø> (+4.09%)` | :arrow_up: | | [...s/SpeziAccount/Mock/MockSimpleAccountService.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FMock%2FMockSimpleAccountService.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvTW9jay9Nb2NrU2ltcGxlQWNjb3VudFNlcnZpY2Uuc3dpZnQ=) | `0.00% <ø> (ø)` | | | [...ccount/Mock/MockUserIdPasswordAccountService.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FMock%2FMockUserIdPasswordAccountService.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvTW9jay9Nb2NrVXNlcklkUGFzc3dvcmRBY2NvdW50U2VydmljZS5zd2lmdA==) | `0.00% <ø> (ø)` | | | [...peziAccount/Views/UserIdPasswordEmbeddedView.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FViews%2FUserIdPasswordEmbeddedView.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvVmlld3MvVXNlcklkUGFzc3dvcmRFbWJlZGRlZFZpZXcuc3dpZnQ=) | `99.03% <ø> (+0.02%)` | :arrow_up: | | ... and [8 more](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) | | ... and [9 files with indirect coverage changes](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Last update [8ac95d7...66d71c1](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/60?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi).