Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor of Supabase.Fetcher #54

Merged
merged 10 commits into from
Jan 10, 2025
Merged

Refactor of Supabase.Fetcher #54

merged 10 commits into from
Jan 10, 2025

Conversation

zoedsoupe
Copy link
Collaborator

@zoedsoupe zoedsoupe commented Jan 5, 2025

Problem

  1. Limited Extensibility for HTTP Requests: The existing Supabase.Fetcher lacked robust support for custom decoders, error parsers, and HTTP client backends, leading to potential limitations when integrating advanced use cases.
  2. Missing Configurability for Supabase Services: Service-specific URLs and configurations were not seamlessly integrated into the Supabase.Fetcher.Request builder, potentially leading to inconsistent setups for applications.
  3. Inconsistent Error Handling: The lack of a centralized error management system meant error messages could be fragmented and harder to debug.
  4. Absence of Detailed Test Coverage: Existing tests did not fully validate the behavior of streaming, file uploads, and custom configurations.

Solution

  1. Enhanced HTTP Request Builder:
    • Introduced a fully extensible request builder API in Supabase.Fetcher.Request that allows chaining methods for custom headers, body decoders, error parsers, and HTTP clients.
    • Added support for service-specific URL handlers (with__url/2) to standardize endpoint configurations for services like auth, storage, and database.
  2. Improved Error Handling:
    • Centralized error management via the Supabase.Error module, defining a unified structure for error codes, messages, metadata, and service-specific origins.
    • Implemented error parsers in Supabase.ErrorParser for handling transport and HTTP errors seamlessly.
  3. Streaming and File Upload Support:
    • Added robust support for streaming large files and consuming streamed responses using Finch.stream/5 in Supabase.Fetcher.Adapter.Finch.
    • Introduced file upload utilities that handle file streams, content-length headers, and MIME type detection automatically.
  4. Tests for Comprehensive Coverage:
    • Enhanced test coverage with unit tests for request building, service-specific configurations, custom decoders, and error parsers.
    • Included tests for file upload, streaming, and error handling scenarios, ensuring edge cases are well-tested.
  5. Documentation and Clarity:
    • Updated module and function documentation to describe key features and example use cases, making it easier for developers to adopt the changes.
    • Added clear examples for implementing custom decoders and error parsers, and using the enhanced request builder API.

Rationale

  1. Developer Productivity: The improved request builder and service-specific configurations reduce boilerplate code and improve consistency across integrations.
  2. Error Debugging: Centralized error handling and detailed metadata in error messages enhance troubleshooting and debugging workflows.
  3. Future-Proof Design: By introducing behaviors and allowing custom implementations for HTTP clients, body decoders, and error parsers, the library becomes extensible for future needs.
  4. Reliability: The expanded test coverage ensures that core features like streaming, file uploads, and error management work as expected across a variety of scenarios.
  5. Alignment with Supabase Ecosystem: These changes make the library a more powerful and idiomatic choice for Elixir developers integrating with Supabase, aligning well with Supabase’s flexibility and developer-first approach.

@zoedsoupe zoedsoupe marked this pull request as ready for review January 7, 2025 14:10
@zoedsoupe zoedsoupe linked an issue Jan 7, 2025 that may be closed by this pull request
@zoedsoupe zoedsoupe changed the base branch from main to fix/52 January 9, 2025 16:47
Base automatically changed from fix/52 to feat/update-elixir January 9, 2025 17:02
@zoedsoupe zoedsoupe merged commit ecf1bf1 into feat/update-elixir Jan 10, 2025
@zoedsoupe zoedsoupe deleted the refactor/51 branch January 10, 2025 22:17
zoedsoupe added a commit that referenced this pull request Jan 10, 2025
## Problem
1. Limited Extensibility for HTTP Requests: The existing
Supabase.Fetcher lacked robust support for custom decoders, error
parsers, and HTTP client backends, leading to potential limitations when
integrating advanced use cases.
2. Missing Configurability for Supabase Services: Service-specific URLs
and configurations were not seamlessly integrated into the
Supabase.Fetcher.Request builder, potentially leading to inconsistent
setups for applications.
3. Inconsistent Error Handling: The lack of a centralized error
management system meant error messages could be fragmented and harder to
debug.
4. Absence of Detailed Test Coverage: Existing tests did not fully
validate the behavior of streaming, file uploads, and custom
configurations.

## Solution
1.	Enhanced HTTP Request Builder:
- Introduced a fully extensible request builder API in
Supabase.Fetcher.Request that allows chaining methods for custom
headers, body decoders, error parsers, and HTTP clients.
- Added support for service-specific URL handlers (with_<service>_url/2)
to standardize endpoint configurations for services like auth, storage,
and database.
2.	Improved Error Handling:
- Centralized error management via the Supabase.Error module, defining a
unified structure for error codes, messages, metadata, and
service-specific origins.
- Implemented error parsers in Supabase.ErrorParser for handling
transport and HTTP errors seamlessly.
3.	Streaming and File Upload Support:
- Added robust support for streaming large files and consuming streamed
responses using Finch.stream/5 in Supabase.Fetcher.Adapter.Finch.
- Introduced file upload utilities that handle file streams,
content-length headers, and MIME type detection automatically.
4.	Tests for Comprehensive Coverage:
- Enhanced test coverage with unit tests for request building,
service-specific configurations, custom decoders, and error parsers.
- Included tests for file upload, streaming, and error handling
scenarios, ensuring edge cases are well-tested.
5.	Documentation and Clarity:
- Updated module and function documentation to describe key features and
example use cases, making it easier for developers to adopt the changes.
- Added clear examples for implementing custom decoders and error
parsers, and using the enhanced request builder API.

## Rationale
1. Developer Productivity: The improved request builder and
service-specific configurations reduce boilerplate code and improve
consistency across integrations.
2. Error Debugging: Centralized error handling and detailed metadata in
error messages enhance troubleshooting and debugging workflows.
3. Future-Proof Design: By introducing behaviors and allowing custom
implementations for HTTP clients, body decoders, and error parsers, the
library becomes extensible for future needs.
4. Reliability: The expanded test coverage ensures that core features
like streaming, file uploads, and error management work as expected
across a variety of scenarios.
5. Alignment with Supabase Ecosystem: These changes make the library a
more powerful and idiomatic choice for Elixir developers integrating
with Supabase, aligning well with Supabase’s flexibility and
developer-first approach.
zoedsoupe added a commit that referenced this pull request Jan 10, 2025
## Problem
1. Limited Extensibility for HTTP Requests: The existing
Supabase.Fetcher lacked robust support for custom decoders, error
parsers, and HTTP client backends, leading to potential limitations when
integrating advanced use cases.
2. Missing Configurability for Supabase Services: Service-specific URLs
and configurations were not seamlessly integrated into the
Supabase.Fetcher.Request builder, potentially leading to inconsistent
setups for applications.
3. Inconsistent Error Handling: The lack of a centralized error
management system meant error messages could be fragmented and harder to
debug.
4. Absence of Detailed Test Coverage: Existing tests did not fully
validate the behavior of streaming, file uploads, and custom
configurations.

## Solution
1.	Enhanced HTTP Request Builder:
- Introduced a fully extensible request builder API in
Supabase.Fetcher.Request that allows chaining methods for custom
headers, body decoders, error parsers, and HTTP clients.
- Added support for service-specific URL handlers (with_<service>_url/2)
to standardize endpoint configurations for services like auth, storage,
and database.
2.	Improved Error Handling:
- Centralized error management via the Supabase.Error module, defining a
unified structure for error codes, messages, metadata, and
service-specific origins.
- Implemented error parsers in Supabase.ErrorParser for handling
transport and HTTP errors seamlessly.
3.	Streaming and File Upload Support:
- Added robust support for streaming large files and consuming streamed
responses using Finch.stream/5 in Supabase.Fetcher.Adapter.Finch.
- Introduced file upload utilities that handle file streams,
content-length headers, and MIME type detection automatically.
4.	Tests for Comprehensive Coverage:
- Enhanced test coverage with unit tests for request building,
service-specific configurations, custom decoders, and error parsers.
- Included tests for file upload, streaming, and error handling
scenarios, ensuring edge cases are well-tested.
5.	Documentation and Clarity:
- Updated module and function documentation to describe key features and
example use cases, making it easier for developers to adopt the changes.
- Added clear examples for implementing custom decoders and error
parsers, and using the enhanced request builder API.

## Rationale
1. Developer Productivity: The improved request builder and
service-specific configurations reduce boilerplate code and improve
consistency across integrations.
2. Error Debugging: Centralized error handling and detailed metadata in
error messages enhance troubleshooting and debugging workflows.
3. Future-Proof Design: By introducing behaviors and allowing custom
implementations for HTTP clients, body decoders, and error parsers, the
library becomes extensible for future needs.
4. Reliability: The expanded test coverage ensures that core features
like streaming, file uploads, and error management work as expected
across a variety of scenarios.
5. Alignment with Supabase Ecosystem: These changes make the library a
more powerful and idiomatic choice for Elixir developers integrating
with Supabase, aligning well with Supabase’s flexibility and
developer-first approach.
zoedsoupe added a commit that referenced this pull request Jan 10, 2025
## Problem
1. Limited Extensibility for HTTP Requests: The existing
Supabase.Fetcher lacked robust support for custom decoders, error
parsers, and HTTP client backends, leading to potential limitations when
integrating advanced use cases.
2. Missing Configurability for Supabase Services: Service-specific URLs
and configurations were not seamlessly integrated into the
Supabase.Fetcher.Request builder, potentially leading to inconsistent
setups for applications.
3. Inconsistent Error Handling: The lack of a centralized error
management system meant error messages could be fragmented and harder to
debug.
4. Absence of Detailed Test Coverage: Existing tests did not fully
validate the behavior of streaming, file uploads, and custom
configurations.

## Solution
1.	Enhanced HTTP Request Builder:
- Introduced a fully extensible request builder API in
Supabase.Fetcher.Request that allows chaining methods for custom
headers, body decoders, error parsers, and HTTP clients.
- Added support for service-specific URL handlers (with_<service>_url/2)
to standardize endpoint configurations for services like auth, storage,
and database.
2.	Improved Error Handling:
- Centralized error management via the Supabase.Error module, defining a
unified structure for error codes, messages, metadata, and
service-specific origins.
- Implemented error parsers in Supabase.ErrorParser for handling
transport and HTTP errors seamlessly.
3.	Streaming and File Upload Support:
- Added robust support for streaming large files and consuming streamed
responses using Finch.stream/5 in Supabase.Fetcher.Adapter.Finch.
- Introduced file upload utilities that handle file streams,
content-length headers, and MIME type detection automatically.
4.	Tests for Comprehensive Coverage:
- Enhanced test coverage with unit tests for request building,
service-specific configurations, custom decoders, and error parsers.
- Included tests for file upload, streaming, and error handling
scenarios, ensuring edge cases are well-tested.
5.	Documentation and Clarity:
- Updated module and function documentation to describe key features and
example use cases, making it easier for developers to adopt the changes.
- Added clear examples for implementing custom decoders and error
parsers, and using the enhanced request builder API.

## Rationale
1. Developer Productivity: The improved request builder and
service-specific configurations reduce boilerplate code and improve
consistency across integrations.
2. Error Debugging: Centralized error handling and detailed metadata in
error messages enhance troubleshooting and debugging workflows.
3. Future-Proof Design: By introducing behaviors and allowing custom
implementations for HTTP clients, body decoders, and error parsers, the
library becomes extensible for future needs.
4. Reliability: The expanded test coverage ensures that core features
like streaming, file uploads, and error management work as expected
across a variety of scenarios.
5. Alignment with Supabase Ecosystem: These changes make the library a
more powerful and idiomatic choice for Elixir developers integrating
with Supabase, aligning well with Supabase’s flexibility and
developer-first approach.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal to refactor and simplify the Supabase.Fetcher module
1 participant