Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Sep 30, 2025

Summary

This PR ports the region functionality from functions-js PR #100 to the Flutter/Dart implementation.

Changes

  • FunctionsClient: Added optional region parameter to constructor and invoke() method
  • Region handling: When region is specified and not 'any':
    • Adds x-region header to the request
    • Adds forceFunctionRegion query parameter to the URL
  • SupabaseClient: Added FunctionsClientOptions to configure default region
  • Tests: Added comprehensive test coverage for region functionality

Features

  • Region can be set at client level (constructor) or per-invocation (invoke method)
  • Per-invocation region overrides client-level region
  • Region value 'any' is treated as no region preference
  • Maintains backward compatibility - all existing code continues to work

Usage Examples

// Set region at client level
final client = FunctionsClient(
  url,
  headers,
  region: 'us-west-1',
);

// Or set region per invocation
await client.invoke('my-function', region: 'eu-west-1');

// Via SupabaseClient
final supabase = SupabaseClient(
  url,
  anonKey,
  functionsOptions: FunctionsClientOptions(region: 'us-east-1'),
);

Test plan

  • All existing tests pass
  • Added new tests for region functionality:
    • Region parameter adds both header and query parameter
    • Region 'any' does not add header or query parameter
    • Client region is used when invoke region is not specified
    • Invoke region overrides client region
    • Region works with other query parameters
  • Code passes dart analyze with no warnings
  • Code formatted with dart format

🤖 Generated with Claude Code

- Add region parameter to FunctionsClient constructor and invoke method
- When region is specified and not 'any', adds both x-region header and forceFunctionRegion query parameter
- Add FunctionsClientOptions to SupabaseClient for configuring default region
- Add comprehensive tests for region functionality
- Maintain backward compatibility with existing code

This feature ports the functionality from functions-js PR #100:
supabase/functions-js#100

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coveralls
Copy link

coveralls commented Sep 30, 2025

Pull Request Test Coverage Report for Build 18144638702

Details

  • 14 of 14 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 80.646%

Totals Coverage Status
Change from base Build 18131530215: 0.05%
Covered Lines: 3146
Relevant Lines: 3901

💛 - Coveralls

@grdsdev grdsdev requested review from a team and Vinzent03 September 30, 2025 20:13
@grdsdev grdsdev requested a review from Vinzent03 September 30, 2025 22:02
@grdsdev grdsdev merged commit 06c35ba into main Sep 30, 2025
15 checks passed
@grdsdev grdsdev deleted the feat/add-force-function-region-query-param branch September 30, 2025 22:12
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.

3 participants