Skip to content

feat(functions): replace FunctionRegion enum with open struct#1053

Open
grdsdev wants to merge 1 commit into
mainfrom
feat/function-region-struct
Open

feat(functions): replace FunctionRegion enum with open struct#1053
grdsdev wants to merge 1 commit into
mainfrom
feat/function-region-struct

Conversation

@grdsdev

@grdsdev grdsdev commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Backports the FunctionRegion type change from release/v3 (part of 02b45208).

What changed: public enum FunctionRegion: Stringpublic struct FunctionRegion: RawRepresentable, Hashable, Sendable with ExpressibleByStringLiteral.

Why: The enum locks users to the 14 hardcoded regions. The struct allows custom values for regions not yet in the SDK:

// new — custom region
options.region = FunctionRegion(rawValue: "custom-region")
options.region = "custom-region"  // via ExpressibleByStringLiteral

// existing — unchanged, still works
options.region = .usEast1
options.region = .caCentral1
let raw = options.region?.rawValue  // still compiles

Migration

No change needed for the vast majority of code — .usEast1, .caCentral1 etc. keep their names, rawValue is unchanged, and FunctionRegion? parameters still accept the same values.

One source-breaking case: exhaustive switch statements over FunctionRegion no longer compile. Add a default: case to fix:

// before
switch region {
case .usEast1: ...
// ❌ compiler error: switch must be exhaustive
}

// after
switch region {
case .usEast1: ...
default: ...
}

Test plan

  • Existing FunctionsClientTests pass unchanged
  • CI green across all platforms

- Change `public enum FunctionRegion: String` to
  `public struct FunctionRegion: RawRepresentable, Hashable, Sendable`
- Add `ExpressibleByStringLiteral` conformance
- All static members retain identical names (.usEast1, .caCentral1, etc.)
- rawValue property is unchanged, so all existing call sites compile
- Custom regions now work: FunctionRegion(rawValue: "custom") or "custom"

BREAKING: exhaustive switch statements over FunctionRegion no longer
compile (add a default: case to fix).

Backport of 02b4520 from release/v3.
@grdsdev grdsdev requested a review from a team as a code owner July 2, 2026 16:49
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ Potential Breaking API Changes Detected

This PR appears to contain breaking API changes. Please review the changes below:

API Check Output
  💔 API breakage: enum FunctionRegion has been changed to a struct
  💔 API breakage: enumelement FunctionRegion.apNortheast1 is now static
  💔 API breakage: enumelement FunctionRegion.apNortheast1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.apNortheast2 is now static
  💔 API breakage: enumelement FunctionRegion.apNortheast2 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.apSouth1 is now static
  💔 API breakage: enumelement FunctionRegion.apSouth1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.apSoutheast1 is now static
  💔 API breakage: enumelement FunctionRegion.apSoutheast1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.apSoutheast2 is now static
  💔 API breakage: enumelement FunctionRegion.apSoutheast2 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.caCentral1 is now static
  💔 API breakage: enumelement FunctionRegion.caCentral1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.euCentral1 is now static
  💔 API breakage: enumelement FunctionRegion.euCentral1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.euWest1 is now static
  💔 API breakage: enumelement FunctionRegion.euWest1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.euWest2 is now static
  💔 API breakage: enumelement FunctionRegion.euWest2 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.euWest3 is now static
  💔 API breakage: enumelement FunctionRegion.euWest3 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.saEast1 is now static
  💔 API breakage: enumelement FunctionRegion.saEast1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.usEast1 is now static
  💔 API breakage: enumelement FunctionRegion.usEast1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.usWest1 is now static
  💔 API breakage: enumelement FunctionRegion.usWest1 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: enumelement FunctionRegion.usWest2 is now static
  💔 API breakage: enumelement FunctionRegion.usWest2 has declared type change from (Functions.FunctionRegion.Type) -> Functions.FunctionRegion to Functions.FunctionRegion
  💔 API breakage: constructor FunctionRegion.init(rawValue:) has return type change from Functions.FunctionRegion? to Functions.FunctionRegion

If this is intentional, please update your PR title or commit message to include:

  • ! after the type (e.g., feat!: remove deprecated method)
  • Or include BREAKING CHANGE: in the commit body

If this is a false positive, you can safely ignore this warning.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 28606932395

Coverage increased (+0.1%) to 81.215%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 3 uncovered changes across 1 file (3 of 6 lines covered, 50.0%).
  • 6 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
Sources/Functions/Types.swift 6 3 50.0%

Coverage Regressions

6 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
Sources/Auth/Internal/Keychain.swift 5 37.23%
Sources/Auth/Storage/KeychainLocalStorage.swift 1 41.67%

Coverage Stats

Coverage Status
Relevant Lines: 9348
Covered Lines: 7592
Line Coverage: 81.22%
Coverage Strength: 36.8 hits per line

💛 - Coveralls

@grdsdev grdsdev changed the title feat(functions): replace FunctionRegion enum with open struct feat(functions)!: replace FunctionRegion enum with open struct Jul 2, 2026
@grdsdev grdsdev changed the title feat(functions)!: replace FunctionRegion enum with open struct feat(functions): replace FunctionRegion enum with open struct Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants