Skip to content

Commit d4b4d68

Browse files
darinfcompnerd
authored andcommitted
FirebaseFunctions API correctness fixes (#64)
Changes: - Make `HTTPSCallableResult.data` public - `FirebaseFunctionsErrorCode` should just be `FunctionsErrorCode`
1 parent 99b05b9 commit d4b4d68

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ target_link_libraries(FirebaseFirestore PUBLIC
200200
zlibstatic)
201201

202202
add_library(FirebaseFunctions SHARED
203-
Sources/FirebaseFunctions/FirebaseFunctionsErrorCode.swift
203+
Sources/FirebaseFunctions/FunctionsErrorCode.swift
204204
Sources/FirebaseFunctions/Functions+Swift.swift
205205
Sources/FirebaseFunctions/HTTPSCallable+Swift.swift
206206
Sources/FirebaseFunctions/HTTPSCallableResult+Swift.swift)

Sources/FirebaseFunctions/FirebaseFunctionsErrorCode.swift renamed to Sources/FirebaseFunctions/FunctionsErrorCode.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import firebase
55
@_spi(FirebaseInternal)
66
import FirebaseCore
77

8-
public struct FirebaseFunctionsErrorCode: Error {
8+
public struct FunctionsErrorCode: Error {
99
public let rawValue: Int
1010
public let localizedDescription: String
1111

@@ -19,7 +19,7 @@ public struct FirebaseFunctionsErrorCode: Error {
1919
}
2020
}
2121

22-
extension FirebaseFunctionsErrorCode: RawRepresentable {
22+
extension FunctionsErrorCode: RawRepresentable {
2323
public typealias RawValue = Int
2424

2525
public init(rawValue: Int) {
@@ -28,7 +28,7 @@ extension FirebaseFunctionsErrorCode: RawRepresentable {
2828
}
2929
}
3030

31-
extension FirebaseFunctionsErrorCode {
31+
extension FunctionsErrorCode {
3232
init(_ error: firebase.functions.Error, errorMessage: String?) {
3333
self.init((code: error.rawValue, message: errorMessage ?? "\(error.rawValue)"))
3434
}
@@ -43,7 +43,7 @@ extension FirebaseFunctionsErrorCode {
4343
}
4444
}
4545

46-
extension FirebaseFunctionsErrorCode {
46+
extension FunctionsErrorCode {
4747
public static var none: Self { .init(firebase.functions.kErrorNone) }
4848
public static var cancelled: Self { .init(firebase.functions.kErrorCancelled) }
4949
public static var unknown: Self { .init(firebase.functions.kErrorUnknown) }
@@ -63,11 +63,11 @@ extension FirebaseFunctionsErrorCode {
6363
public static var dataLoss: Self { .init(firebase.functions.kErrorDataLoss) }
6464
}
6565

66-
extension FirebaseFunctionsErrorCode: Equatable {}
66+
extension FunctionsErrorCode: Equatable {}
6767

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

7272
// This allows us to re-expose self as a code similarly
7373
// to what the Firebase SDK does when it creates the

Sources/FirebaseFunctions/HTTPSCallable+Swift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class HTTPSCallable {
3939
let variant = try! toVariant(data)
4040
let future = swift_firebase.swift_cxx_shims.firebase.functions.https_callable_call(impl, variant)
4141
future.setCompletion({
42-
let (result, error) = future.resultAndError { FirebaseFunctionsErrorCode($0) }
42+
let (result, error) = future.resultAndError { FunctionsErrorCode($0) }
4343
completion(result.map { .init($0) }, error)
4444
})
4545
}

Sources/FirebaseFunctions/HTTPSCallableResult+Swift.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import CxxShim
99
import Foundation
1010

1111
public class HTTPSCallableResult {
12-
let data: Any
12+
public let data: Any
1313

1414
init(_ result: firebase.functions.HttpsCallableResult = .init()) {
1515
let variant = swift_firebase.swift_cxx_shims.firebase.functions.https_callable_result_data(result)

0 commit comments

Comments
 (0)