Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import PackageDescription
let package = Package(
name: "Supabase",
platforms: [
.iOS(.v13),
.macCatalyst(.v13),
.macOS(.v10_15),
.watchOS(.v6),
.tvOS(.v13),
.iOS(.v16),
.macCatalyst(.v16),
.macOS(.v13),
.watchOS(.v9),
.tvOS(.v16),
],
products: [
.library(name: "Auth", targets: ["Auth"]),
Expand Down
10 changes: 5 additions & 5 deletions Package@swift-6.1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import PackageDescription
let package = Package(
name: "Supabase",
platforms: [
.iOS(.v13),
.macCatalyst(.v13),
.macOS(.v10_15),
.watchOS(.v6),
.tvOS(.v13),
.iOS(.v16),
.macCatalyst(.v16),
.macOS(.v13),
.watchOS(.v9),
.tvOS(.v16),
],
products: [
.library(name: "Auth", targets: ["Auth"]),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Supabase SDK for Swift. Mirrors the design of [supabase-js](https://github.com/s
## Usage

### Requirements
- iOS 13.0+ / macOS 10.15+ / tvOS 13+ / watchOS 6+ / visionOS 1+
- iOS 16.0+ / macOS 13+ / tvOS 16+ / watchOS 9+ / visionOS 1+
- Xcode 15.3+
- Swift 5.10+

Expand Down
1 change: 0 additions & 1 deletion Sources/Auth/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
private let globalJWKSCache = GlobalJWKSCache()

public actor AuthClient {
static var globalClientID = 0

Check warning on line 63 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, MACOS, 26.0)

static property 'globalClientID' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode

Check warning on line 63 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (IOS, 26.0)

static property 'globalClientID' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode

Check warning on line 63 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (MACOS, 26.0)

static property 'globalClientID' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode

Check warning on line 63 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, IOS, 26.0)

static property 'globalClientID' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode

Check warning on line 63 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, IOS, 26.0)

static property 'globalClientID' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode

Check warning on line 63 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / Examples

static property 'globalClientID' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode
nonisolated let clientID: AuthClientID

nonisolated private var api: APIClient { Dependencies[clientID].api }
Expand Down Expand Up @@ -122,8 +122,8 @@
/// - Parameters:
/// - configuration: The client configuration.
public init(configuration: Configuration) {
AuthClient.globalClientID += 1

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MAC_CATALYST, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MAC_CATALYST, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MAC_CATALYST, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MACOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 125 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (IOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6
clientID = AuthClient.globalClientID

Check warning on line 126 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 126 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 126 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 126 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 126 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MAC_CATALYST, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 126 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MAC_CATALYST, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 126 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MACOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Check warning on line 126 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (IOS, 15.4)

reference to static property 'globalClientID' is not concurrency-safe because it involves shared mutable state; this is an error in Swift 6

Dependencies[clientID] = Dependencies(
configuration: configuration,
Expand All @@ -133,7 +133,7 @@
sessionStorage: .live(clientID: clientID),
sessionManager: .live(clientID: clientID),
logger: configuration.logger.map {
AuthClientLoggerDecorator(clientID: clientID, decoratee: $0)

Check warning on line 136 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

nonisolated property 'clientID' can not be referenced from a non-isolated context; this is an error in Swift 6

Check warning on line 136 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

nonisolated property 'clientID' can not be referenced from a non-isolated context; this is an error in Swift 6

Check warning on line 136 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

nonisolated property 'clientID' can not be referenced from a non-isolated context; this is an error in Swift 6

Check warning on line 136 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

nonisolated property 'clientID' can not be referenced from a non-isolated context; this is an error in Swift 6

Check warning on line 136 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MAC_CATALYST, 15.4)

nonisolated property 'clientID' can not be referenced from a non-isolated context; this is an error in Swift 6

Check warning on line 136 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MAC_CATALYST, 15.4)

nonisolated property 'clientID' can not be referenced from a non-isolated context; this is an error in Swift 6

Check warning on line 136 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MACOS, 15.4)

nonisolated property 'clientID' can not be referenced from a non-isolated context; this is an error in Swift 6

Check warning on line 136 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (IOS, 15.4)

nonisolated property 'clientID' can not be referenced from a non-isolated context; this is an error in Swift 6
}
)

Expand Down Expand Up @@ -367,7 +367,7 @@
method: .post,
query: [URLQueryItem(name: "grant_type", value: "password")],
body: configuration.encoder.encode(
UserCredentials(

Check warning on line 370 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, MACOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 370 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (MACOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 370 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (IOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 370 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, IOS, 26.0)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.
email: email,
password: password,
gotrueMetaSecurity: captchaToken.map(AuthMetaSecurity.init(captchaToken:))
Expand All @@ -394,7 +394,7 @@
method: .post,
query: [URLQueryItem(name: "grant_type", value: "password")],
body: configuration.encoder.encode(
UserCredentials(

Check warning on line 397 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (test, MACOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 397 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (MACOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.

Check warning on line 397 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS latest) (IOS, 16.4)

'UserCredentials' is deprecated: Access to UserCredentials will be removed on the next major release.
password: password,
phone: phone,
gotrueMetaSecurity: captchaToken.map(AuthMetaSecurity.init(captchaToken:))
Expand Down Expand Up @@ -702,7 +702,6 @@
/// - Note: This method support the PKCE flow.
/// - Warning: Do not call `start()` on the `ASWebAuthenticationSession` object inside the
/// `configure` closure, as the method implementation calls it already.
@available(watchOS 6.2, tvOS 16.0, *)
@discardableResult
public func signInWithOAuth(
provider: Provider,
Expand Down Expand Up @@ -1674,7 +1673,7 @@
final class DefaultPresentationContextProvider: NSObject,
ASWebAuthenticationPresentationContextProviding
{
func presentationAnchor(for _: ASWebAuthenticationSession) -> ASPresentationAnchor {

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MAC_CATALYST, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MAC_CATALYST, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MAC_CATALYST, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MACOS, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement

Check warning on line 1676 in Sources/Auth/AuthClient.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (IOS, 15.4)

main actor-isolated instance method 'presentationAnchor(for:)' cannot be used to satisfy nonisolated protocol requirement
ASPresentationAnchor()
}
}
Expand Down
88 changes: 32 additions & 56 deletions Sources/Functions/FunctionsClient.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ConcurrencyExtras
import Foundation
import HTTPTypes

Expand All @@ -9,11 +8,12 @@ import HTTPTypes
let version = Helpers.version

/// An actor representing a client for invoking functions.
public final class FunctionsClient: Sendable {
public actor FunctionsClient {
/// Fetch handler used to make requests.
public typealias FetchHandler = @Sendable (_ request: URLRequest) async throws -> (
Data, URLResponse
)
public typealias FetchHandler =
@Sendable (_ request: URLRequest) async throws -> (
Data, URLResponse
)

/// Request idle timeout: 150s (If an Edge Function doesn't send a response before the timeout, 504 Gateway Timeout will be returned)
///
Expand All @@ -24,21 +24,14 @@ public final class FunctionsClient: Sendable {
let url: URL

/// The Region to invoke the functions in.
let region: String?
let region: FunctionRegion?

struct MutableState {
/// Headers to be included in the requests.
var headers = HTTPFields()
}
/// Headers to be included in the requests.
var headers = HTTPFields()

private let http: any HTTPClientType
private let mutableState = LockIsolated(MutableState())
private let sessionConfiguration: URLSessionConfiguration

var headers: HTTPFields {
mutableState.headers
}

/// Initializes a new instance of `FunctionsClient`.
///
/// - Parameters:
Expand All @@ -47,11 +40,10 @@ public final class FunctionsClient: Sendable {
/// - region: The Region to invoke the functions in.
/// - logger: SupabaseLogger instance to use.
/// - fetch: The fetch handler used to make requests. (Default: URLSession.shared.data(for:))
@_disfavoredOverload
public convenience init(
public init(
url: URL,
headers: [String: String] = [:],
region: String? = nil,
region: FunctionRegion? = nil,
logger: (any SupabaseLogger)? = nil,
fetch: @escaping FetchHandler = { try await URLSession.shared.data(for: $0) }
) {
Expand All @@ -65,10 +57,10 @@ public final class FunctionsClient: Sendable {
)
}

convenience init(
init(
url: URL,
headers: [String: String] = [:],
region: String? = nil,
region: FunctionRegion? = nil,
logger: (any SupabaseLogger)? = nil,
fetch: @escaping FetchHandler = { try await URLSession.shared.data(for: $0) },
sessionConfiguration: URLSessionConfiguration
Expand All @@ -92,7 +84,7 @@ public final class FunctionsClient: Sendable {
init(
url: URL,
headers: [String: String],
region: String?,
region: FunctionRegion?,
http: any HTTPClientType,
sessionConfiguration: URLSessionConfiguration = .default
) {
Expand All @@ -101,42 +93,20 @@ public final class FunctionsClient: Sendable {
self.http = http
self.sessionConfiguration = sessionConfiguration

mutableState.withValue {
$0.headers = HTTPFields(headers)
if $0.headers[.xClientInfo] == nil {
$0.headers[.xClientInfo] = "functions-swift/\(version)"
}
self.headers = HTTPFields(headers)
if self.headers[.xClientInfo] == nil {
self.headers[.xClientInfo] = "functions-swift/\(version)"
}
}

/// Initializes a new instance of `FunctionsClient`.
///
/// - Parameters:
/// - url: The base URL for the functions.
/// - headers: Headers to be included in the requests. (Default: empty dictionary)
/// - region: The Region to invoke the functions in.
/// - logger: SupabaseLogger instance to use.
/// - fetch: The fetch handler used to make requests. (Default: URLSession.shared.data(for:))
public convenience init(
url: URL,
headers: [String: String] = [:],
region: FunctionRegion? = nil,
logger: (any SupabaseLogger)? = nil,
fetch: @escaping FetchHandler = { try await URLSession.shared.data(for: $0) }
) {
self.init(url: url, headers: headers, region: region?.rawValue, logger: logger, fetch: fetch)
}

/// Updates the authorization header.
///
/// - Parameter token: The new JWT token sent in the authorization header.
public func setAuth(token: String?) {
mutableState.withValue {
if let token {
$0.headers[.authorization] = "Bearer \(token)"
} else {
$0.headers[.authorization] = nil
}
if let token {
headers[.authorization] = "Bearer \(token)"
} else {
headers[.authorization] = nil
}
}

Expand All @@ -154,7 +124,8 @@ public final class FunctionsClient: Sendable {
decode: (Data, HTTPURLResponse) throws -> Response
) async throws -> Response {
let response = try await rawInvoke(
functionName: functionName, invokeOptions: options
functionName: functionName,
invokeOptions: options
)
return try decode(response.data, response.underlyingResponse)
}
Expand Down Expand Up @@ -226,7 +197,10 @@ public final class FunctionsClient: Sendable {
let delegate = StreamResponseDelegate(continuation: continuation)

let session = URLSession(
configuration: sessionConfiguration, delegate: delegate, delegateQueue: nil)
configuration: sessionConfiguration,
delegate: delegate,
delegateQueue: nil
)

let urlRequest = buildRequest(functionName: functionName, options: invokeOptions).urlRequest

Expand All @@ -251,14 +225,14 @@ public final class FunctionsClient: Sendable {
url: url.appendingPathComponent(functionName),
method: FunctionInvokeOptions.httpMethod(options.method) ?? .post,
query: query,
headers: mutableState.headers.merging(with: options.headers),
headers: headers.merging(with: options.headers),
body: options.body,
timeoutInterval: FunctionsClient.requestIdleTimeout
)

if let region = options.region ?? region {
request.headers[.xRegion] = region
query.appendOrUpdate(URLQueryItem(name: "forceFunctionRegion", value: region))
request.headers[.xRegion] = region.rawValue
query.appendOrUpdate(URLQueryItem(name: "forceFunctionRegion", value: region.rawValue))
request.query = query
}

Expand All @@ -282,7 +256,9 @@ final class StreamResponseDelegate: NSObject, URLSessionDataDelegate, Sendable {
}

func urlSession(
_: URLSession, dataTask _: URLSessionDataTask, didReceive response: URLResponse,
_: URLSession,
dataTask _: URLSessionDataTask,
didReceive response: URLResponse,
completionHandler: @escaping (URLSession.ResponseDisposition) -> Void
) {
defer {
Expand Down
79 changes: 25 additions & 54 deletions Sources/Functions/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct FunctionInvokeOptions: Sendable {
/// Body data to be sent with the function invocation.
let body: Data?
/// The Region to invoke the function in.
let region: String?
let region: FunctionRegion?
/// The query to be included in the function invocation.
let query: [URLQueryItem]

Expand All @@ -40,12 +40,11 @@ public struct FunctionInvokeOptions: Sendable {
/// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
/// - region: The Region to invoke the function in.
/// - body: The body data to be sent with the function invocation. (Default: nil)
@_disfavoredOverload
public init(
method: Method? = nil,
query: [URLQueryItem] = [],
headers: [String: String] = [:],
region: String? = nil,
region: FunctionRegion? = nil,
body: some Encodable
) {
var defaultHeaders = HTTPFields()
Expand Down Expand Up @@ -76,12 +75,11 @@ public struct FunctionInvokeOptions: Sendable {
/// - query: The query to be included in the function invocation.
/// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
/// - region: The Region to invoke the function in.
@_disfavoredOverload
public init(
method: Method? = nil,
query: [URLQueryItem] = [],
headers: [String: String] = [:],
region: String? = nil
region: FunctionRegion? = nil
) {
self.method = method
self.headers = HTTPFields(headers)
Expand Down Expand Up @@ -116,56 +114,29 @@ public struct FunctionInvokeOptions: Sendable {
}
}

public enum FunctionRegion: String, Sendable {
case apNortheast1 = "ap-northeast-1"
case apNortheast2 = "ap-northeast-2"
case apSouth1 = "ap-south-1"
case apSoutheast1 = "ap-southeast-1"
case apSoutheast2 = "ap-southeast-2"
case caCentral1 = "ca-central-1"
case euCentral1 = "eu-central-1"
case euWest1 = "eu-west-1"
case euWest2 = "eu-west-2"
case euWest3 = "eu-west-3"
case saEast1 = "sa-east-1"
case usEast1 = "us-east-1"
case usWest1 = "us-west-1"
case usWest2 = "us-west-2"
}

extension FunctionInvokeOptions {
/// Initializes the `FunctionInvokeOptions` structure.
///
/// - Parameters:
/// - method: Method to use in the function invocation.
/// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
/// - region: The Region to invoke the function in.
/// - body: The body data to be sent with the function invocation. (Default: nil)
public init(
method: Method? = nil,
headers: [String: String] = [:],
region: FunctionRegion? = nil,
body: some Encodable
) {
self.init(
method: method,
headers: headers,
region: region?.rawValue,
body: body
)
public struct FunctionRegion: RawRepresentable, Sendable {
public let rawValue: String
public init(rawValue: String) {
self.rawValue = rawValue
}

/// Initializes the `FunctionInvokeOptions` structure.
///
/// - Parameters:
/// - method: Method to use in the function invocation.
/// - headers: Headers to be included in the function invocation. (Default: empty dictionary)
/// - region: The Region to invoke the function in.
public init(
method: Method? = nil,
headers: [String: String] = [:],
region: FunctionRegion? = nil
) {
self.init(method: method, headers: headers, region: region?.rawValue)
public static let apNortheast1 = FunctionRegion(rawValue: "ap-northeast-1")
public static let apNortheast2 = FunctionRegion(rawValue: "ap-northeast-2")
public static let apSouth1 = FunctionRegion(rawValue: "ap-south-1")
public static let apSoutheast1 = FunctionRegion(rawValue: "ap-southeast-1")
public static let apSoutheast2 = FunctionRegion(rawValue: "ap-southeast-2")
public static let caCentral1 = FunctionRegion(rawValue: "ca-central-1")
public static let euCentral1 = FunctionRegion(rawValue: "eu-central-1")
public static let euWest1 = FunctionRegion(rawValue: "eu-west-1")
public static let euWest2 = FunctionRegion(rawValue: "eu-west-2")
public static let euWest3 = FunctionRegion(rawValue: "eu-west-3")
public static let saEast1 = FunctionRegion(rawValue: "sa-east-1")
public static let usEast1 = FunctionRegion(rawValue: "us-east-1")
public static let usWest1 = FunctionRegion(rawValue: "us-west-1")
public static let usWest2 = FunctionRegion(rawValue: "us-west-2")
}
extension FunctionRegion: ExpressibleByStringLiteral {
public init(stringLiteral value: String) {
self.init(rawValue: value)
}
}
1 change: 0 additions & 1 deletion Sources/Helpers/Logger/OSLogSupabaseLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
/// options: .init(global: .init(logger: supabaseLogger))
/// )
/// ```
@available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *)
public struct OSLogSupabaseLogger: SupabaseLogger {
private let logger: Logger

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, IOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MACOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MAC_CATALYST, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MAC_CATALYST, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MAC_CATALYST, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MAC_CATALYST, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MAC_CATALYST, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (test, MAC_CATALYST, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MACOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MACOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MACOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (MACOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (IOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (IOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (IOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

Check warning on line 27 in Sources/Helpers/Logger/OSLogSupabaseLogger.swift

View workflow job for this annotation

GitHub Actions / xcodebuild (macOS legacy) (IOS, 15.4)

stored property 'logger' of 'Sendable'-conforming struct 'OSLogSupabaseLogger' has non-sendable type 'Logger'

/// Creates a new OSLog-based logger with a provided Logger instance.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/Helpers/Task+withTimeout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package func withTimeout<R: Sendable>(
group.addTask {
let interval = deadline.timeIntervalSinceNow
if interval > 0 {
try await _clock.sleep(for: interval)
try await _clock.sleep(for: .seconds(interval))
}
try Task.checkCancellation()
throw TimeoutError()
Expand Down
Loading
Loading