Improve and fix client options parsing #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
This PR addresses the following issues:
The Supabase client was throwing an error (
function Supabase.Client.Auth.changeset/2 is undefined or private
) when initializing with anauth
key in the options map. Specifically, the functionSupabase.Client.Auth.changeset/3
required asupabase_uri
, but this wasn't properly handled during initialization, leading to crashes when theauth
entry was present in the options.Minor inconsistencies in documentation and examples, making it harder for developers to use the library and configure client options properly.
Solution
Refactored the
Supabase.Client
options parsing to handle theauth
key correctly, ensuring the appropriate arguments are passed toSupabase.Client.Auth.changeset/2
.Improved documentation and examples in the
README.md
to clarify usage of client options, including proper handling of theauth
key.Updated related module and function documentation (
@doc
,@typedoc
) to reflect the changes and ensure consistency.Added and updated tests to verify the behavior when initializing clients with custom options, including edge cases such as setting
flow_type
inauth
, while correctly handle default options and merging.Rationale
The changes were implemented to fix issue #45, ensuring developers can use the
auth
key in client options without encountering errors. Refactoring the options parsing logic and enhancing documentation improves the overall developer experience, aligns with best practices, and avoids ambiguity in API usage.By making the
auth
configuration fully functional and improving examples, this PR resolves the root cause of the reported issue and reduces the likelihood of similar misunderstandings in the future.