From 4f73f571bb20e30c838575c0ea4d6fc5021baef4 Mon Sep 17 00:00:00 2001 From: Come CHEVALLIER Date: Mon, 10 Jul 2017 13:12:51 +0200 Subject: [PATCH] Firebase 3 + Naming Collisions fix --- Nora.xcodeproj/project.pbxproj | 102 ++++++++++++++++++++------------- Nora/DatabaseProvider.swift | 10 ++-- Nora/DatabaseRequest.swift | 10 ++-- Nora/DatabaseResponse.swift | 8 +-- Nora/FirebaseTarget.swift | 20 +++---- Nora/FirebaseTask.swift | 33 ++++------- Nora/NoraError.swift | 0 Nora/Result.swift | 0 Nora/StorageProvider.swift | 24 ++++---- Nora/StorageRequest.swift | 4 +- Nora/StorageResponse.swift | 4 +- 11 files changed, 111 insertions(+), 104 deletions(-) mode change 100644 => 100755 Nora/DatabaseProvider.swift mode change 100644 => 100755 Nora/DatabaseRequest.swift mode change 100644 => 100755 Nora/DatabaseResponse.swift mode change 100644 => 100755 Nora/FirebaseTarget.swift mode change 100644 => 100755 Nora/FirebaseTask.swift mode change 100644 => 100755 Nora/NoraError.swift mode change 100644 => 100755 Nora/Result.swift mode change 100644 => 100755 Nora/StorageProvider.swift mode change 100644 => 100755 Nora/StorageRequest.swift mode change 100644 => 100755 Nora/StorageResponse.swift diff --git a/Nora.xcodeproj/project.pbxproj b/Nora.xcodeproj/project.pbxproj index c024a95..285c53c 100644 --- a/Nora.xcodeproj/project.pbxproj +++ b/Nora.xcodeproj/project.pbxproj @@ -10,16 +10,26 @@ 07E554301E96B33C00D81D9B /* NoraTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07E5542F1E96B33C00D81D9B /* NoraTests.swift */; }; 07E554321E96B33C00D81D9B /* Nora.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B062C6CF1E946B59006C3CB8 /* Nora.framework */; }; 4C3DA810DFDAB2B7494B5061 /* Pods_Nora.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C4C9489816D143B076B1BA00 /* Pods_Nora.framework */; }; - B0602A3C1E98F03D0087BBD9 /* DatabaseProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A321E98F03D0087BBD9 /* DatabaseProvider.swift */; }; - B0602A3D1E98F03D0087BBD9 /* StorageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A331E98F03D0087BBD9 /* StorageProvider.swift */; }; - B0602A3E1E98F03D0087BBD9 /* FirebaseTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A341E98F03D0087BBD9 /* FirebaseTarget.swift */; }; - B0602A3F1E98F03D0087BBD9 /* FirebaseTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A351E98F03D0087BBD9 /* FirebaseTask.swift */; }; - B0602A401E98F03D0087BBD9 /* DatabaseRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A361E98F03D0087BBD9 /* DatabaseRequest.swift */; }; - B0602A411E98F03D0087BBD9 /* DatabaseResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A371E98F03D0087BBD9 /* DatabaseResponse.swift */; }; - B0602A421E98F03D0087BBD9 /* StorageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A381E98F03D0087BBD9 /* StorageRequest.swift */; }; - B0602A431E98F03D0087BBD9 /* StorageResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A391E98F03D0087BBD9 /* StorageResponse.swift */; }; - B0602A441E98F03D0087BBD9 /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A3A1E98F03D0087BBD9 /* Result.swift */; }; - B0602A451E98F03D0087BBD9 /* NoraError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0602A3B1E98F03D0087BBD9 /* NoraError.swift */; }; + 5D97DDA21F13989200C5926F /* DatabaseProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD981F13989200C5926F /* DatabaseProvider.swift */; }; + 5D97DDA31F13989200C5926F /* DatabaseProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD981F13989200C5926F /* DatabaseProvider.swift */; }; + 5D97DDA41F13989200C5926F /* DatabaseRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD991F13989200C5926F /* DatabaseRequest.swift */; }; + 5D97DDA51F13989200C5926F /* DatabaseRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD991F13989200C5926F /* DatabaseRequest.swift */; }; + 5D97DDA61F13989200C5926F /* DatabaseResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9A1F13989200C5926F /* DatabaseResponse.swift */; }; + 5D97DDA71F13989200C5926F /* DatabaseResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9A1F13989200C5926F /* DatabaseResponse.swift */; }; + 5D97DDA81F13989200C5926F /* FirebaseTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9B1F13989200C5926F /* FirebaseTarget.swift */; }; + 5D97DDA91F13989200C5926F /* FirebaseTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9B1F13989200C5926F /* FirebaseTarget.swift */; }; + 5D97DDAA1F13989200C5926F /* FirebaseTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9C1F13989200C5926F /* FirebaseTask.swift */; }; + 5D97DDAB1F13989200C5926F /* FirebaseTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9C1F13989200C5926F /* FirebaseTask.swift */; }; + 5D97DDAC1F13989200C5926F /* NoraError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9D1F13989200C5926F /* NoraError.swift */; }; + 5D97DDAD1F13989200C5926F /* NoraError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9D1F13989200C5926F /* NoraError.swift */; }; + 5D97DDAE1F13989200C5926F /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9E1F13989200C5926F /* Result.swift */; }; + 5D97DDAF1F13989200C5926F /* Result.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9E1F13989200C5926F /* Result.swift */; }; + 5D97DDB01F13989200C5926F /* StorageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9F1F13989200C5926F /* StorageProvider.swift */; }; + 5D97DDB11F13989200C5926F /* StorageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DD9F1F13989200C5926F /* StorageProvider.swift */; }; + 5D97DDB21F13989200C5926F /* StorageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DDA01F13989200C5926F /* StorageRequest.swift */; }; + 5D97DDB31F13989200C5926F /* StorageRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DDA01F13989200C5926F /* StorageRequest.swift */; }; + 5D97DDB41F13989200C5926F /* StorageResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DDA11F13989200C5926F /* StorageResponse.swift */; }; + 5D97DDB51F13989200C5926F /* StorageResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5D97DDA11F13989200C5926F /* StorageResponse.swift */; }; B062C6E01E946B59006C3CB8 /* Nora.h in Headers */ = {isa = PBXBuildFile; fileRef = B062C6D21E946B59006C3CB8 /* Nora.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ @@ -41,16 +51,16 @@ 2A493DF63E18ED29F60987EC /* Pods-NoraTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NoraTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-NoraTests/Pods-NoraTests.debug.xcconfig"; sourceTree = ""; }; 47BBF9BAF2B1F6B0AE961F4B /* Pods-NoraTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NoraTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-NoraTests/Pods-NoraTests.release.xcconfig"; sourceTree = ""; }; 5C9D2F34406916531BC82016 /* Pods_NoraTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NoraTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - B0602A321E98F03D0087BBD9 /* DatabaseProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseProvider.swift; sourceTree = ""; }; - B0602A331E98F03D0087BBD9 /* StorageProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageProvider.swift; sourceTree = ""; }; - B0602A341E98F03D0087BBD9 /* FirebaseTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseTarget.swift; sourceTree = ""; }; - B0602A351E98F03D0087BBD9 /* FirebaseTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseTask.swift; sourceTree = ""; }; - B0602A361E98F03D0087BBD9 /* DatabaseRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRequest.swift; sourceTree = ""; }; - B0602A371E98F03D0087BBD9 /* DatabaseResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseResponse.swift; sourceTree = ""; }; - B0602A381E98F03D0087BBD9 /* StorageRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageRequest.swift; sourceTree = ""; }; - B0602A391E98F03D0087BBD9 /* StorageResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageResponse.swift; sourceTree = ""; }; - B0602A3A1E98F03D0087BBD9 /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = ""; }; - B0602A3B1E98F03D0087BBD9 /* NoraError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoraError.swift; sourceTree = ""; }; + 5D97DD981F13989200C5926F /* DatabaseProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseProvider.swift; sourceTree = ""; }; + 5D97DD991F13989200C5926F /* DatabaseRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseRequest.swift; sourceTree = ""; }; + 5D97DD9A1F13989200C5926F /* DatabaseResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseResponse.swift; sourceTree = ""; }; + 5D97DD9B1F13989200C5926F /* FirebaseTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseTarget.swift; sourceTree = ""; }; + 5D97DD9C1F13989200C5926F /* FirebaseTask.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FirebaseTask.swift; sourceTree = ""; }; + 5D97DD9D1F13989200C5926F /* NoraError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoraError.swift; sourceTree = ""; }; + 5D97DD9E1F13989200C5926F /* Result.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Result.swift; sourceTree = ""; }; + 5D97DD9F1F13989200C5926F /* StorageProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageProvider.swift; sourceTree = ""; }; + 5D97DDA01F13989200C5926F /* StorageRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageRequest.swift; sourceTree = ""; }; + 5D97DDA11F13989200C5926F /* StorageResponse.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageResponse.swift; sourceTree = ""; }; B062C6CF1E946B59006C3CB8 /* Nora.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Nora.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B062C6D21E946B59006C3CB8 /* Nora.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Nora.h; sourceTree = ""; }; B062C6D31E946B59006C3CB8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -130,16 +140,16 @@ B062C7091E947363006C3CB8 /* Sources */ = { isa = PBXGroup; children = ( - B0602A321E98F03D0087BBD9 /* DatabaseProvider.swift */, - B0602A331E98F03D0087BBD9 /* StorageProvider.swift */, - B0602A341E98F03D0087BBD9 /* FirebaseTarget.swift */, - B0602A351E98F03D0087BBD9 /* FirebaseTask.swift */, - B0602A361E98F03D0087BBD9 /* DatabaseRequest.swift */, - B0602A371E98F03D0087BBD9 /* DatabaseResponse.swift */, - B0602A381E98F03D0087BBD9 /* StorageRequest.swift */, - B0602A391E98F03D0087BBD9 /* StorageResponse.swift */, - B0602A3A1E98F03D0087BBD9 /* Result.swift */, - B0602A3B1E98F03D0087BBD9 /* NoraError.swift */, + 5D97DD981F13989200C5926F /* DatabaseProvider.swift */, + 5D97DD991F13989200C5926F /* DatabaseRequest.swift */, + 5D97DD9A1F13989200C5926F /* DatabaseResponse.swift */, + 5D97DD9B1F13989200C5926F /* FirebaseTarget.swift */, + 5D97DD9C1F13989200C5926F /* FirebaseTask.swift */, + 5D97DD9D1F13989200C5926F /* NoraError.swift */, + 5D97DD9E1F13989200C5926F /* Result.swift */, + 5D97DD9F1F13989200C5926F /* StorageProvider.swift */, + 5D97DDA01F13989200C5926F /* StorageRequest.swift */, + 5D97DDA11F13989200C5926F /* StorageResponse.swift */, ); name = Sources; sourceTree = ""; @@ -230,7 +240,7 @@ }; B062C6CE1E946B59006C3CB8 = { CreatedOnToolsVersion = 8.2.1; - LastSwiftMigration = 0820; + LastSwiftMigration = 0830; ProvisioningStyle = Automatic; }; }; @@ -309,6 +319,16 @@ buildActionMask = 2147483647; files = ( 07E554301E96B33C00D81D9B /* NoraTests.swift in Sources */, + 5D97DDAD1F13989200C5926F /* NoraError.swift in Sources */, + 5D97DDB51F13989200C5926F /* StorageResponse.swift in Sources */, + 5D97DDA71F13989200C5926F /* DatabaseResponse.swift in Sources */, + 5D97DDA91F13989200C5926F /* FirebaseTarget.swift in Sources */, + 5D97DDB11F13989200C5926F /* StorageProvider.swift in Sources */, + 5D97DDA31F13989200C5926F /* DatabaseProvider.swift in Sources */, + 5D97DDA51F13989200C5926F /* DatabaseRequest.swift in Sources */, + 5D97DDAF1F13989200C5926F /* Result.swift in Sources */, + 5D97DDAB1F13989200C5926F /* FirebaseTask.swift in Sources */, + 5D97DDB31F13989200C5926F /* StorageRequest.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -316,16 +336,16 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - B0602A441E98F03D0087BBD9 /* Result.swift in Sources */, - B0602A421E98F03D0087BBD9 /* StorageRequest.swift in Sources */, - B0602A3D1E98F03D0087BBD9 /* StorageProvider.swift in Sources */, - B0602A411E98F03D0087BBD9 /* DatabaseResponse.swift in Sources */, - B0602A3F1E98F03D0087BBD9 /* FirebaseTask.swift in Sources */, - B0602A431E98F03D0087BBD9 /* StorageResponse.swift in Sources */, - B0602A3C1E98F03D0087BBD9 /* DatabaseProvider.swift in Sources */, - B0602A3E1E98F03D0087BBD9 /* FirebaseTarget.swift in Sources */, - B0602A451E98F03D0087BBD9 /* NoraError.swift in Sources */, - B0602A401E98F03D0087BBD9 /* DatabaseRequest.swift in Sources */, + 5D97DDB01F13989200C5926F /* StorageProvider.swift in Sources */, + 5D97DDB21F13989200C5926F /* StorageRequest.swift in Sources */, + 5D97DDA41F13989200C5926F /* DatabaseRequest.swift in Sources */, + 5D97DDA61F13989200C5926F /* DatabaseResponse.swift in Sources */, + 5D97DDAA1F13989200C5926F /* FirebaseTask.swift in Sources */, + 5D97DDA21F13989200C5926F /* DatabaseProvider.swift in Sources */, + 5D97DDB41F13989200C5926F /* StorageResponse.swift in Sources */, + 5D97DDAE1F13989200C5926F /* Result.swift in Sources */, + 5D97DDAC1F13989200C5926F /* NoraError.swift in Sources */, + 5D97DDA81F13989200C5926F /* FirebaseTarget.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Nora/DatabaseProvider.swift b/Nora/DatabaseProvider.swift old mode 100644 new mode 100755 index 7d84178..db40fd5 --- a/Nora/DatabaseProvider.swift +++ b/Nora/DatabaseProvider.swift @@ -10,7 +10,7 @@ import Foundation import FirebaseDatabase public typealias DatabaseCompletion = (Result) -> Void -public typealias TransactionBlock = (FIRMutableData) -> FIRTransactionResult +public typealias TransactionBlock = (MutableData) -> TransactionResult public class DatabaseProvider { @@ -39,7 +39,7 @@ public class DatabaseProvider { private func processObserve(_ request: DatabaseQueryRequest, _ completion: @escaping DatabaseCompletion) -> UInt? { - let successMapping = { (snapshot: FIRDataSnapshot) in + let successMapping = { (snapshot: DataSnapshot) in let result = self.convertResponseToResult(snapshot: snapshot, reference: request.query.ref, error: nil) completion(result) } @@ -65,7 +65,7 @@ public class DatabaseProvider { private func processWrite(_ request: DatabaseRequest, _ completion: @escaping DatabaseCompletion) { - let completionBlock = { (error: Error?, reference: FIRDatabaseReference) in + let completionBlock = { (error: Error?, reference: DatabaseReference) in let result = self.convertResponseToResult(snapshot: nil, reference: reference, error: error) completion(result) } @@ -102,7 +102,7 @@ public class DatabaseProvider { private func processTransaction(_ request: DatabaseRequest, _ completion: @escaping DatabaseCompletion) { - let transactionCompletion = { (error: Error?, committed: Bool, snapshot: FIRDataSnapshot?) in + let transactionCompletion = { (error: Error?, committed: Bool, snapshot: DataSnapshot?) in let result = self.convertResponseToResult(snapshot: snapshot, reference: request.reference, error: error, committed: committed) completion(result) } @@ -114,7 +114,7 @@ public class DatabaseProvider { private extension DatabaseProvider { - func convertResponseToResult(snapshot: FIRDataSnapshot?, reference: FIRDatabaseReference?, error: Error?, committed: Bool? = nil) -> Result { + func convertResponseToResult(snapshot: DataSnapshot?, reference: DatabaseReference?, error: Error?, committed: Bool? = nil) -> Result { switch (snapshot, reference, error, committed) { case let (snapshot, .some(reference), .none, .some(committed)): diff --git a/Nora/DatabaseRequest.swift b/Nora/DatabaseRequest.swift old mode 100644 new mode 100755 index bfd34a2..d65f6bb --- a/Nora/DatabaseRequest.swift +++ b/Nora/DatabaseRequest.swift @@ -13,9 +13,9 @@ import FirebaseDatabase struct DatabaseRequest { - var reference: FIRDatabaseReference - var task: DatabaseTask - var transactionBlock: (FIRMutableData) -> FIRTransactionResult + var reference: DatabaseReference + var task: NRDatabaseTask + var transactionBlock: (MutableData) -> TransactionResult var onDisconnect: Bool var localEvents: Bool @@ -36,8 +36,8 @@ extension DatabaseRequest { struct DatabaseQueryRequest { - var query: FIRDatabaseQuery - var task: DatabaseTask + var query: DatabaseQuery + var task: NRDatabaseTask } diff --git a/Nora/DatabaseResponse.swift b/Nora/DatabaseResponse.swift old mode 100644 new mode 100755 index 31db2c2..0a859d9 --- a/Nora/DatabaseResponse.swift +++ b/Nora/DatabaseResponse.swift @@ -21,14 +21,14 @@ public protocol JSONDecodeable { public struct DatabaseResponse { - public let snapshot: FIRDataSnapshot? - public let reference: FIRDatabaseReference + public let snapshot: DataSnapshot? + public let reference: DatabaseReference public let isCommitted: Bool } public extension DatabaseResponse { - init(reference: FIRDatabaseReference, snapshot: FIRDataSnapshot? = nil, isCommitted: Bool = false) { + init(reference: DatabaseReference, snapshot: DataSnapshot? = nil, isCommitted: Bool = false) { self.reference = reference self.snapshot = snapshot self.isCommitted = isCommitted @@ -97,7 +97,7 @@ public extension DatabaseResponse { var result: [[String: Any]] = [] for child in snapshot.children { - guard let snapshot = child as? FIRDataSnapshot, let json = snapshot.value as? [String: Any] else { + guard let snapshot = child as? DataSnapshot, let json = snapshot.value as? [String: Any] else { throw NoraError.jsonMapping } diff --git a/Nora/FirebaseTarget.swift b/Nora/FirebaseTarget.swift old mode 100644 new mode 100755 index 8621d2b..f5c485a --- a/Nora/FirebaseTarget.swift +++ b/Nora/FirebaseTarget.swift @@ -28,19 +28,19 @@ public extension FirebaseTarget { public protocol DatabaseTarget: FirebaseTarget { /// Base reference for your target in Database - var baseReference: FIRDatabaseReference { get } + var baseReference: DatabaseReference { get } /// Path to be appended to the base reference var path: String { get } /// Type of task you want to perform ( Firebase method: eg. observe, observeOnce, setValue, etc. ) - var task: DatabaseTask { get } + var task: NRDatabaseTask { get } /// Queries to append to the end of the path in order as listed - var queries: [DatabaseQuery]? { get } + var queries: [NRDatabaseQuery]? { get } /// Transaction block to run for .transaction task ( Defaults to FIRTransactionResult.success(withValue: FIRMutableData) ) - var transactionBlock: (FIRMutableData) -> FIRTransactionResult { get } + var transactionBlock: (MutableData) -> TransactionResult { get } /// Should task be performed on disconnect ( Defaults to false ) var onDisconnect: Bool { get } @@ -53,7 +53,7 @@ public protocol DatabaseTarget: FirebaseTarget { public extension DatabaseTarget { /// Queries to append to the end of the path in order as listed - var queries: [DatabaseQuery]? { + var queries: [NRDatabaseQuery]? { return nil } @@ -68,9 +68,9 @@ public extension DatabaseTarget { } /// Transaction block to run for .transaction task ( Defaults to FIRTransactionResult.success(withValue: FIRMutableData) ) - var transactionBlock: (FIRMutableData) -> FIRTransactionResult { - return { (data: FIRMutableData) in - return FIRTransactionResult.success(withValue: data) + var transactionBlock: (MutableData) -> TransactionResult { + return { (data: MutableData) in + return TransactionResult.success(withValue: data) } } } @@ -80,12 +80,12 @@ public extension DatabaseTarget { public protocol StorageTarget: FirebaseTarget { /// Base reference for your target in Storage - var baseReference: FIRStorageReference { get } + var baseReference: StorageReference { get } /// Path to be appended to the base reference var path: String { get } /// Type of task you want to perform ( Firebase storage method: eg. put, putFile, write, delete ) - var task: StorageTask { get } + var task: NRStorageTask { get } } diff --git a/Nora/FirebaseTask.swift b/Nora/FirebaseTask.swift old mode 100644 new mode 100755 index 7f16ac9..278f846 --- a/Nora/FirebaseTask.swift +++ b/Nora/FirebaseTask.swift @@ -13,10 +13,10 @@ import FirebaseStorage // MARK: - DatabaseTask /// Represents the read/write methods of Firebase -public enum DatabaseTask { +public enum NRDatabaseTask { - case observe(FIRDataEventType) - case observeOnce(FIRDataEventType) + case observe(DataEventType) + case observeOnce(DataEventType) case setValue(Any?) case updateChildValues([AnyHashable: Any]) case removeValue @@ -27,15 +27,15 @@ public enum DatabaseTask { // MARK: - StorageTask /// Represents the read/write methods of FirebaseStorage -public enum StorageTask { +public enum NRStorageTask { - case upload(Data, FIRStorageMetadata?) // put - case uploadFile(to: URL, FIRStorageMetadata?) // putFile + case upload(Data, StorageMetadata?) // put + case uploadFile(to: URL, StorageMetadata?) // putFile case downloadData(maxSize: Int64) // data case downloadToURL(URL) // write case downloadURL // downloadURL case downloadMetadata // metadata - case update(FIRStorageMetadata) // update + case update(StorageMetadata) // update case delete // delete } @@ -43,7 +43,7 @@ public enum StorageTask { // MARK: - DatabaseQuery /// Represents the FIRDatabaseQuery methods -public enum DatabaseQuery { +public enum NRDatabaseQuery { case limitedFirst(UInt) // queryLimited(toFirst limit: UInt) case limitedLast(UInt) // queryLimited(toLast limit: UInt) @@ -60,9 +60,9 @@ public enum DatabaseQuery { } -public extension DatabaseQuery { +public extension NRDatabaseQuery { - func prepare(_ query: FIRDatabaseQuery) -> FIRDatabaseQuery { + func prepare(_ query: DatabaseQuery) -> DatabaseQuery { switch self { case .limitedFirst(let n): @@ -93,16 +93,3 @@ public extension DatabaseQuery { } } - - - - - - - - - - - - - diff --git a/Nora/NoraError.swift b/Nora/NoraError.swift old mode 100644 new mode 100755 diff --git a/Nora/Result.swift b/Nora/Result.swift old mode 100644 new mode 100755 diff --git a/Nora/StorageProvider.swift b/Nora/StorageProvider.swift old mode 100644 new mode 100755 index 3a8e28b..031db39 --- a/Nora/StorageProvider.swift +++ b/Nora/StorageProvider.swift @@ -14,7 +14,7 @@ public typealias StorageCompletion = (Result) -> Void public class StorageProvider { @discardableResult - public func request(_ target: Target, completion: @escaping StorageCompletion) -> FIRStorageObservableTask? { + public func request(_ target: Target, completion: @escaping StorageCompletion) -> StorageObservableTask? { let request = StorageRequest(target) @@ -26,9 +26,9 @@ public class StorageProvider { } } - private func processUpload(_ request: StorageRequest, _ completion: @escaping StorageCompletion) -> FIRStorageUploadTask? { + private func processUpload(_ request: StorageRequest, _ completion: @escaping StorageCompletion) -> StorageUploadTask? { - let writeBlock = { (metaData: FIRStorageMetadata?, error: Error?) in + let writeBlock = { (metaData: StorageMetadata?, error: Error?) in let response = self.convertResponseToResult(data: nil, metaData: metaData, url: nil, error: error) completion(response) } @@ -38,17 +38,17 @@ public class StorageProvider { completion(response) } - var uploadTask: FIRStorageUploadTask? + var uploadTask: StorageUploadTask? switch request.task { case .upload(let data, let metaData): - uploadTask = request.reference.put(data, metadata: metaData, completion: writeBlock) + uploadTask = request.reference.putData(data, metadata: metaData, completion: writeBlock) case .uploadFile(let url, let metaData): - uploadTask = request.reference.putFile(url, metadata: metaData, completion: writeBlock) + uploadTask = request.reference.putFile(from: url, metadata: metaData, completion: writeBlock) case .update(let metadata): - request.reference.update(metadata, completion: writeBlock) + request.reference.updateMetadata(metadata, completion: writeBlock) case .downloadMetadata: // this is really a download task - request.reference.metadata(completion: writeBlock) + request.reference.getMetadata(completion: writeBlock) case .delete: request.reference.delete(completion: deleteBlock) default: @@ -58,7 +58,7 @@ public class StorageProvider { return uploadTask } - private func processDownload(_ request: StorageRequest, _ completion: @escaping StorageCompletion) -> FIRStorageDownloadTask? { + private func processDownload(_ request: StorageRequest, _ completion: @escaping StorageCompletion) -> StorageDownloadTask? { let dataCompletion = { (data: Data?, error: Error?) in let response = self.convertResponseToResult(data: data, metaData: nil, url: nil, error: error) @@ -70,11 +70,11 @@ public class StorageProvider { completion(response) } - var downloadTask: FIRStorageDownloadTask? + var downloadTask: StorageDownloadTask? switch request.task { case .downloadData(let maxSize): - downloadTask = request.reference.data(withMaxSize: maxSize, completion: dataCompletion) + downloadTask = request.reference.getData(maxSize: maxSize, completion: dataCompletion) case .downloadToURL(let url): downloadTask = request.reference.write(toFile: url, completion: urlCompletion) case .downloadURL: @@ -89,7 +89,7 @@ public class StorageProvider { private extension StorageProvider { - func convertResponseToResult(data: Data?, metaData: FIRStorageMetadata?, url: URL?, error: Error?) -> Result { + func convertResponseToResult(data: Data?, metaData: StorageMetadata?, url: URL?, error: Error?) -> Result { switch (data, metaData, url, error) { case let (.some(data), _, _, .none): diff --git a/Nora/StorageRequest.swift b/Nora/StorageRequest.swift old mode 100644 new mode 100755 index 7711b26..5f331ad --- a/Nora/StorageRequest.swift +++ b/Nora/StorageRequest.swift @@ -13,8 +13,8 @@ import FirebaseStorage struct StorageRequest { - let reference: FIRStorageReference - let task: StorageTask + let reference: StorageReference + let task: NRStorageTask } diff --git a/Nora/StorageResponse.swift b/Nora/StorageResponse.swift old mode 100644 new mode 100755 index 4e7075f..4d76199 --- a/Nora/StorageResponse.swift +++ b/Nora/StorageResponse.swift @@ -14,7 +14,7 @@ import FirebaseStorage public struct StorageResponse { let data: Data? - let metaData: FIRStorageMetadata? + let metaData: StorageMetadata? let url: URL? } @@ -33,7 +33,7 @@ public extension StorageResponse { self.data = nil } - init(metaData: FIRStorageMetadata) { + init(metaData: StorageMetadata) { self.metaData = metaData self.url = nil self.data = nil