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

Encoding and Decoding of AccountDetails with strongly typed configuration #69

Closed Supereg closed 2 months ago

Supereg commented 2 months ago

Encoding and Decoding of AccountDetails with strongly typed configuration

:recycle: Current situation & Problem

The current approach of decoding and encoding AccountDetails relies on setting the expected userInfo keys on the encoder and decoder instance. While is highlighted in documentation, there is no compile-time check that there isn't any mistake in the configuration (e.g., missing keys or values with unexpected type). iOS 17 introduced the CodableWithConfiguration protocols that allow to set a configuration type for encoding and decoding. This PR migrates the current approach to adopting the EncodableWithConfiguration protocol and replacing the Decodable conformance with DecodableWithConfiguration. The requirement to pass a configuration upon decoding is now expressed with the type system and will produce a compiler warning if not done correctly.

:gear: Release Notes

:books: Documentation

Documentation was added for new interfaces and updated to point to the new configuration types.

:white_check_mark: Testing

Existing unit test verify that the new implementation doesn't break any expected behavior.

: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 2 months ago

Codecov Report

Attention: Patch coverage is 95.65217% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.82%. Comparing base (40fa3f5) to head (0d9eb77). Report is 1 commits behind head on main.

Files Patch % Lines
...ountValue/Collections/AccountDetails+Codable.swift 95.00% 1 Missing :warning:
Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/69/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/69?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi) ```diff @@ Coverage Diff @@ ## main #69 +/- ## ========================================== + Coverage 84.45% 84.82% +0.37% ========================================== Files 120 120 Lines 5202 5170 -32 ========================================== - Hits 4393 4385 -8 + Misses 809 785 -24 ``` | [Files](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/69?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/AccountDetailsCache.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/69?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountDetailsCache.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudERldGFpbHNDYWNoZS5zd2lmdA==) | `92.11% <100.00%> (+0.22%)` | :arrow_up: | | [...ount/AccountValue/Collections/AccountDetails.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/69?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountValue%2FCollections%2FAccountDetails.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFZhbHVlL0NvbGxlY3Rpb25zL0FjY291bnREZXRhaWxzLnN3aWZ0) | `73.83% <ø> (ø)` | | | [...ccount/AccountValue/Keys/AccountDetailsFlags.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/69?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountValue%2FKeys%2FAccountDetailsFlags.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFZhbHVlL0tleXMvQWNjb3VudERldGFpbHNGbGFncy5zd2lmdA==) | `75.52% <ø> (ø)` | | | [...ountValue/Collections/AccountDetails+Codable.swift](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/69?src=pr&el=tree&filepath=Sources%2FSpeziAccount%2FAccountValue%2FCollections%2FAccountDetails%2BCodable.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi#diff-U291cmNlcy9TcGV6aUFjY291bnQvQWNjb3VudFZhbHVlL0NvbGxlY3Rpb25zL0FjY291bnREZXRhaWxzK0NvZGFibGUuc3dpZnQ=) | `78.45% <95.00%> (+11.12%)` | :arrow_up: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/69?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/69?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=StanfordSpezi). Last update [40fa3f5...0d9eb77](https://app.codecov.io/gh/StanfordSpezi/SpeziAccount/pull/69?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).