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

FirebaseFunctions API correctness fixes #64

Merged
merged 2 commits into from
May 14, 2024
Merged
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ target_link_libraries(FirebaseFirestore PUBLIC
zlibstatic)

add_library(FirebaseFunctions SHARED
Sources/FirebaseFunctions/FirebaseFunctionsErrorCode.swift
Sources/FirebaseFunctions/FunctionsErrorCode.swift
Sources/FirebaseFunctions/Functions+Swift.swift
Sources/FirebaseFunctions/HTTPSCallable+Swift.swift
Sources/FirebaseFunctions/HTTPSCallableResult+Swift.swift)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import firebase
@_spi(FirebaseInternal)
import FirebaseCore

public struct FirebaseFunctionsErrorCode: Error {
public struct FunctionsErrorCode: Error {
public let rawValue: Int
public let localizedDescription: String

Expand All @@ -19,7 +19,7 @@ public struct FirebaseFunctionsErrorCode: Error {
}
}

extension FirebaseFunctionsErrorCode: RawRepresentable {
extension FunctionsErrorCode: RawRepresentable {
public typealias RawValue = Int

public init(rawValue: Int) {
Expand All @@ -28,7 +28,7 @@ extension FirebaseFunctionsErrorCode: RawRepresentable {
}
}

extension FirebaseFunctionsErrorCode {
extension FunctionsErrorCode {
init(_ error: firebase.functions.Error, errorMessage: String?) {
self.init((code: error.rawValue, message: errorMessage ?? "\(error.rawValue)"))
}
Expand All @@ -43,7 +43,7 @@ extension FirebaseFunctionsErrorCode {
}
}

extension FirebaseFunctionsErrorCode {
extension FunctionsErrorCode {
public static var none: Self { .init(firebase.functions.kErrorNone) }
public static var cancelled: Self { .init(firebase.functions.kErrorCancelled) }
public static var unknown: Self { .init(firebase.functions.kErrorUnknown) }
Expand All @@ -63,11 +63,11 @@ extension FirebaseFunctionsErrorCode {
public static var dataLoss: Self { .init(firebase.functions.kErrorDataLoss) }
}

extension FirebaseFunctionsErrorCode: Equatable {}
extension FunctionsErrorCode: Equatable {}

extension FirebaseFunctionsErrorCode {
extension FunctionsErrorCode {
// The Obj C API provides this type as well, so provide it here for consistency.
public typealias Code = FirebaseFunctionsErrorCode
public typealias Code = FunctionsErrorCode

// This allows us to re-expose self as a code similarly
// to what the Firebase SDK does when it creates the
Expand Down
2 changes: 1 addition & 1 deletion Sources/FirebaseFunctions/HTTPSCallable+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class HTTPSCallable {
let variant = try! toVariant(data)
let future = swift_firebase.swift_cxx_shims.firebase.functions.https_callable_call(impl, variant)
future.setCompletion({
let (result, error) = future.resultAndError { FirebaseFunctionsErrorCode($0) }
let (result, error) = future.resultAndError { FunctionsErrorCode($0) }
completion(result.map { .init($0) }, error)
})
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/FirebaseFunctions/HTTPSCallableResult+Swift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CxxShim
import Foundation

public class HTTPSCallableResult {
let data: Any
public let data: Any

init(_ result: firebase.functions.HttpsCallableResult = .init()) {
let variant = swift_firebase.swift_cxx_shims.firebase.functions.https_callable_result_data(result)
Expand Down
Loading