From b4e5ad7dff42711e9e74c6499fbadee4f59f407a Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 3 Aug 2022 22:58:21 +0100 Subject: [PATCH] Refactor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cmix → cMix Cmix → CMix --- .../example-app/Sources/AppFeature/App.swift | 10 +- .../Sources/AppFeature/AppFeature.swift | 16 +-- .../LandingFeature/LandingFeature.swift | 96 ++++++++-------- .../Sources/LandingFeature/LandingView.swift | 28 ++--- .../SessionFeature/SessionFeature.swift | 18 +-- .../AppFeatureTests/AppFeatureTests.swift | 20 ++-- .../LandingFeatureTests.swift | 108 +++++++++--------- .../SessionFeatureTests.swift | 22 ++-- Sources/ElixxirDAppsSDK/CMix/CMix.swift | 58 ++++++++++ .../Functors/CMixAddHealthCallback.swift} | 16 +-- .../Functors/CMixConnect.swift} | 16 +-- .../CMix/Functors/CMixGetId.swift | 22 ++++ ...ptionRegistrationValidationSignature.swift | 27 +++++ .../Functors/CMixHasRunningProcesses.swift | 22 ++++ .../CMix/Functors/CMixIsHealthy.swift | 22 ++++ .../CMixMakeLegacyReceptionIdentity.swift | 25 ++++ .../Functors/CMixMakeReceptionIdentity.swift | 25 ++++ .../Functors/CMixNetworkFollowerStatus.swift | 26 +++++ .../CMixRegisterClientErrorCallback.swift | 28 +++++ .../Functors/CMixStartNetworkFollower.swift | 24 ++++ .../Functors/CMixStopNetworkFollower.swift | 22 ++++ .../CMixWaitForMessageDelivery.swift} | 14 +-- .../Functors/CMixWaitForNetwork.swift} | 12 +- Sources/ElixxirDAppsSDK/Cmix/Cmix.swift | 58 ---------- .../Cmix/Functors/CmixGetId.swift | 22 ---- ...ptionRegistrationValidationSignature.swift | 27 ----- .../Functors/CmixHasRunningProcesses.swift | 22 ---- .../Cmix/Functors/CmixIsHealthy.swift | 22 ---- .../CmixMakeLegacyReceptionIdentity.swift | 25 ---- .../Functors/CmixMakeReceptionIdentity.swift | 25 ---- .../Functors/CmixNetworkFollowerStatus.swift | 26 ----- .../CmixRegisterClientErrorCallback.swift | 28 ----- .../Functors/CmixStartNetworkFollower.swift | 24 ---- .../Functors/CmixStopNetworkFollower.swift | 22 ---- .../{CmixManager.swift => CMixManager.swift} | 36 +++--- ...erCreate.swift => CMixManagerCreate.swift} | 28 ++--- ...rage.swift => CMixManagerHasStorage.swift} | 12 +- .../Functors/CMixManagerLoad.swift | 32 ++++++ ...erRemove.swift => CMixManagerRemove.swift} | 12 +- .../Functors/CmixManagerLoad.swift | 32 ------ ...etCmixParams.swift => GetCMixParams.swift} | 10 +- .../Functors/GetFileTransferParams.swift | 2 +- .../Functors/GetSingleUseParams.swift | 2 +- .../ElixxirDAppsSDK/Functors/LoadCMix.swift | 34 ++++++ .../ElixxirDAppsSDK/Functors/LoadCmix.swift | 34 ------ .../Functors/LoadReceptionIdentity.swift | 8 +- Sources/ElixxirDAppsSDK/Functors/Login.swift | 10 +- .../Functors/NewBroadcastChannel.swift | 8 +- .../Functors/{NewCmix.swift => NewCMix.swift} | 12 +- ...omBackup.swift => NewCMixFromBackup.swift} | 12 +- .../Functors/StoreReceptionIdentity.swift | 8 +- 51 files changed, 635 insertions(+), 635 deletions(-) create mode 100644 Sources/ElixxirDAppsSDK/CMix/CMix.swift rename Sources/ElixxirDAppsSDK/{Cmix/Functors/CmixAddHealthCallback.swift => CMix/Functors/CMixAddHealthCallback.swift} (51%) rename Sources/ElixxirDAppsSDK/{Cmix/Functors/CmixConnect.swift => CMix/Functors/CMixConnect.swift} (67%) create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixGetId.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixGetReceptionRegistrationValidationSignature.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixHasRunningProcesses.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixIsHealthy.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixMakeLegacyReceptionIdentity.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixMakeReceptionIdentity.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixNetworkFollowerStatus.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixRegisterClientErrorCallback.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixStartNetworkFollower.swift create mode 100644 Sources/ElixxirDAppsSDK/CMix/Functors/CMixStopNetworkFollower.swift rename Sources/ElixxirDAppsSDK/{Cmix/Functors/CmixWaitForMessageDelivery.swift => CMix/Functors/CMixWaitForMessageDelivery.swift} (60%) rename Sources/ElixxirDAppsSDK/{Cmix/Functors/CmixWaitForNetwork.swift => CMix/Functors/CMixWaitForNetwork.swift} (57%) delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Cmix.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetId.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetReceptionRegistrationValidationSignature.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixHasRunningProcesses.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixIsHealthy.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeLegacyReceptionIdentity.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeReceptionIdentity.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixNetworkFollowerStatus.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixRegisterClientErrorCallback.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStartNetworkFollower.swift delete mode 100644 Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStopNetworkFollower.swift rename Sources/ElixxirDAppsSDK/CmixManager/{CmixManager.swift => CMixManager.swift} (66%) rename Sources/ElixxirDAppsSDK/CmixManager/Functors/{CmixManagerCreate.swift => CMixManagerCreate.swift} (66%) rename Sources/ElixxirDAppsSDK/CmixManager/Functors/{CmixManagerHasStorage.swift => CMixManagerHasStorage.swift} (65%) create mode 100644 Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerLoad.swift rename Sources/ElixxirDAppsSDK/CmixManager/Functors/{CmixManagerRemove.swift => CMixManagerRemove.swift} (63%) delete mode 100644 Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerLoad.swift rename Sources/ElixxirDAppsSDK/Functors/{GetCmixParams.swift => GetCMixParams.swift} (64%) create mode 100644 Sources/ElixxirDAppsSDK/Functors/LoadCMix.swift delete mode 100644 Sources/ElixxirDAppsSDK/Functors/LoadCmix.swift rename Sources/ElixxirDAppsSDK/Functors/{NewCmix.swift => NewCMix.swift} (71%) rename Sources/ElixxirDAppsSDK/Functors/{NewCmixFromBackup.swift => NewCMixFromBackup.swift} (77%) diff --git a/Example/example-app/Sources/AppFeature/App.swift b/Example/example-app/Sources/AppFeature/App.swift index 2ad3db43..3392af19 100644 --- a/Example/example-app/Sources/AppFeature/App.swift +++ b/Example/example-app/Sources/AppFeature/App.swift @@ -21,7 +21,7 @@ struct App: SwiftUI.App { extension AppEnvironment { static func live() -> AppEnvironment { - let cmixSubject = CurrentValueSubject<Cmix?, Never>(nil) + let cMixSubject = CurrentValueSubject<CMix?, Never>(nil) let mainScheduler = DispatchQueue.main.eraseToAnyScheduler() let bgScheduler = DispatchQueue( label: "xx.network.dApps.ExampleApp.bg", @@ -30,19 +30,19 @@ extension AppEnvironment { return AppEnvironment( makeId: UUID.init, - hasCmix: { cmixSubject.map { $0 != nil }.eraseToAnyPublisher() }, + hasCMix: { cMixSubject.map { $0 != nil }.eraseToAnyPublisher() }, mainScheduler: mainScheduler, landing: LandingEnvironment( - cmixManager: .live( + cMixManager: .live( passwordStorage: .keychain ), - setCmix: { cmixSubject.value = $0 }, + setCMix: { cMixSubject.value = $0 }, bgScheduler: bgScheduler, mainScheduler: mainScheduler, error: ErrorEnvironment() ), session: SessionEnvironment( - getCmix: { cmixSubject.value }, + getCMix: { cMixSubject.value }, bgScheduler: bgScheduler, mainScheduler: mainScheduler, error: ErrorEnvironment() diff --git a/Example/example-app/Sources/AppFeature/AppFeature.swift b/Example/example-app/Sources/AppFeature/AppFeature.swift index f9ce0287..3f521a12 100644 --- a/Example/example-app/Sources/AppFeature/AppFeature.swift +++ b/Example/example-app/Sources/AppFeature/AppFeature.swift @@ -41,14 +41,14 @@ extension AppState.Scene { enum AppAction: Equatable { case viewDidLoad - case cmixDidChange(hasCmix: Bool) + case cMixDidChange(hasCMix: Bool) case landing(LandingAction) case session(SessionAction) } struct AppEnvironment { var makeId: () -> UUID - var hasCmix: () -> AnyPublisher<Bool, Never> + var hasCMix: () -> AnyPublisher<Bool, Never> var mainScheduler: AnySchedulerOf<DispatchQueue> var landing: LandingEnvironment var session: SessionEnvironment @@ -56,18 +56,18 @@ struct AppEnvironment { let appReducer = Reducer<AppState, AppAction, AppEnvironment> { state, action, env in - enum HasCmixEffectId {} + enum HasCMixEffectId {} switch action { case .viewDidLoad: - return env.hasCmix() + return env.hasCMix() .removeDuplicates() - .map(AppAction.cmixDidChange(hasCmix:)) + .map(AppAction.cMixDidChange(hasCMix:)) .receive(on: env.mainScheduler) .eraseToEffect() - .cancellable(id: HasCmixEffectId.self, cancelInFlight: true) + .cancellable(id: HasCMixEffectId.self, cancelInFlight: true) - case .cmixDidChange(let hasClient): + case .cMixDidChange(let hasClient): if hasClient { let sessionState = state.scene.asSession ?? SessionState(id: env.makeId()) state.scene = .session(sessionState) @@ -99,7 +99,7 @@ let appReducer = Reducer<AppState, AppAction, AppEnvironment> extension AppEnvironment { static let unimplemented = AppEnvironment( makeId: XCTUnimplemented("\(Self.self).makeId"), - hasCmix: XCTUnimplemented("\(Self.self).hasCmix"), + hasCMix: XCTUnimplemented("\(Self.self).hasCMix"), mainScheduler: .unimplemented, landing: .unimplemented, session: .unimplemented diff --git a/Example/example-app/Sources/LandingFeature/LandingFeature.swift b/Example/example-app/Sources/LandingFeature/LandingFeature.swift index f8fa2d9d..8de2eb33 100644 --- a/Example/example-app/Sources/LandingFeature/LandingFeature.swift +++ b/Example/example-app/Sources/LandingFeature/LandingFeature.swift @@ -7,54 +7,54 @@ import XCTestDynamicOverlay public struct LandingState: Equatable { public init( id: UUID, - hasStoredCmix: Bool = false, - isMakingCmix: Bool = false, - isRemovingCmix: Bool = false, + hasStoredCMix: Bool = false, + isMakingCMix: Bool = false, + isRemovingCMix: Bool = false, error: ErrorState? = nil ) { self.id = id - self.hasStoredCmix = hasStoredCmix - self.isMakingCmix = isMakingCmix - self.isRemovingCmix = isRemovingCmix + self.hasStoredCMix = hasStoredCMix + self.isMakingCMix = isMakingCMix + self.isRemovingCMix = isRemovingCMix self.error = error } var id: UUID - var hasStoredCmix: Bool - var isMakingCmix: Bool - var isRemovingCmix: Bool + var hasStoredCMix: Bool + var isMakingCMix: Bool + var isRemovingCMix: Bool var error: ErrorState? } public enum LandingAction: Equatable { case viewDidLoad - case makeCmix - case didMakeCmix - case didFailMakingCmix(NSError) - case removeStoredCmix - case didRemoveStoredCmix - case didFailRemovingStoredCmix(NSError) + case makeCMix + case didMakeCMix + case didFailMakingCMix(NSError) + case removeStoredCMix + case didRemoveStoredCMix + case didFailRemovingStoredCMix(NSError) case didDismissError case error(ErrorAction) } public struct LandingEnvironment { public init( - cmixManager: CmixManager, - setCmix: @escaping (Cmix) -> Void, + cMixManager: CMixManager, + setCMix: @escaping (CMix) -> Void, bgScheduler: AnySchedulerOf<DispatchQueue>, mainScheduler: AnySchedulerOf<DispatchQueue>, error: ErrorEnvironment ) { - self.cmixManager = cmixManager - self.setCmix = setCmix + self.cMixManager = cMixManager + self.setCMix = setCMix self.bgScheduler = bgScheduler self.mainScheduler = mainScheduler self.error = error } - public var cmixManager: CmixManager - public var setCmix: (Cmix) -> Void + public var cMixManager: CMixManager + public var setCMix: (CMix) -> Void public var bgScheduler: AnySchedulerOf<DispatchQueue> public var mainScheduler: AnySchedulerOf<DispatchQueue> public var error: ErrorEnvironment @@ -64,60 +64,60 @@ public let landingReducer = Reducer<LandingState, LandingAction, LandingEnvironm { state, action, env in switch action { case .viewDidLoad: - state.hasStoredCmix = env.cmixManager.hasStorage() + state.hasStoredCMix = env.cMixManager.hasStorage() return .none - case .makeCmix: - state.isMakingCmix = true + case .makeCMix: + state.isMakingCMix = true return Effect.future { fulfill in do { - if env.cmixManager.hasStorage() { - env.setCmix(try env.cmixManager.load()) + if env.cMixManager.hasStorage() { + env.setCMix(try env.cMixManager.load()) } else { - env.setCmix(try env.cmixManager.create()) + env.setCMix(try env.cMixManager.create()) } - fulfill(.success(.didMakeCmix)) + fulfill(.success(.didMakeCMix)) } catch { - fulfill(.success(.didFailMakingCmix(error as NSError))) + fulfill(.success(.didFailMakingCMix(error as NSError))) } } .subscribe(on: env.bgScheduler) .receive(on: env.mainScheduler) .eraseToEffect() - case .didMakeCmix: - state.isMakingCmix = false - state.hasStoredCmix = env.cmixManager.hasStorage() + case .didMakeCMix: + state.isMakingCMix = false + state.hasStoredCMix = env.cMixManager.hasStorage() return .none - case .didFailMakingCmix(let error): - state.isMakingCmix = false - state.hasStoredCmix = env.cmixManager.hasStorage() + case .didFailMakingCMix(let error): + state.isMakingCMix = false + state.hasStoredCMix = env.cMixManager.hasStorage() state.error = ErrorState(error: error) return .none - case .removeStoredCmix: - state.isRemovingCmix = true + case .removeStoredCMix: + state.isRemovingCMix = true return Effect.future { fulfill in do { - try env.cmixManager.remove() - fulfill(.success(.didRemoveStoredCmix)) + try env.cMixManager.remove() + fulfill(.success(.didRemoveStoredCMix)) } catch { - fulfill(.success(.didFailRemovingStoredCmix(error as NSError))) + fulfill(.success(.didFailRemovingStoredCMix(error as NSError))) } } .subscribe(on: env.bgScheduler) .receive(on: env.mainScheduler) .eraseToEffect() - case .didRemoveStoredCmix: - state.isRemovingCmix = false - state.hasStoredCmix = env.cmixManager.hasStorage() + case .didRemoveStoredCMix: + state.isRemovingCMix = false + state.hasStoredCMix = env.cMixManager.hasStorage() return .none - case .didFailRemovingStoredCmix(let error): - state.isRemovingCmix = false - state.hasStoredCmix = env.cmixManager.hasStorage() + case .didFailRemovingStoredCMix(let error): + state.isRemovingCMix = false + state.hasStoredCMix = env.cMixManager.hasStorage() state.error = ErrorState(error: error) return .none @@ -136,8 +136,8 @@ public let landingReducer = Reducer<LandingState, LandingAction, LandingEnvironm extension LandingEnvironment { public static let unimplemented = LandingEnvironment( - cmixManager: .unimplemented, - setCmix: XCTUnimplemented("\(Self.self).setCmix"), + cMixManager: .unimplemented, + setCMix: XCTUnimplemented("\(Self.self).setCMix"), bgScheduler: .unimplemented, mainScheduler: .unimplemented, error: .unimplemented diff --git a/Example/example-app/Sources/LandingFeature/LandingView.swift b/Example/example-app/Sources/LandingFeature/LandingView.swift index f52aeebb..e6903c2e 100644 --- a/Example/example-app/Sources/LandingFeature/LandingView.swift +++ b/Example/example-app/Sources/LandingFeature/LandingView.swift @@ -11,19 +11,19 @@ public struct LandingView: View { let store: Store<LandingState, LandingAction> struct ViewState: Equatable { - let hasStoredCmix: Bool - let isMakingCmix: Bool - let isRemovingCmix: Bool + let hasStoredCMix: Bool + let isMakingCMix: Bool + let isRemovingCMix: Bool init(state: LandingState) { - hasStoredCmix = state.hasStoredCmix - isMakingCmix = state.isMakingCmix - isRemovingCmix = state.isRemovingCmix + hasStoredCMix = state.hasStoredCMix + isMakingCMix = state.isMakingCMix + isRemovingCMix = state.isRemovingCMix } var isLoading: Bool { - isMakingCmix || - isRemovingCmix + isMakingCMix || + isRemovingCMix } } @@ -31,25 +31,25 @@ public struct LandingView: View { WithViewStore(store.scope(state: ViewState.init)) { viewStore in Form { Button { - viewStore.send(.makeCmix) + viewStore.send(.makeCMix) } label: { HStack { - Text(viewStore.hasStoredCmix ? "Load stored cMix" : "Create new cMix") + Text(viewStore.hasStoredCMix ? "Load stored cMix" : "Create new cMix") Spacer() - if viewStore.isMakingCmix { + if viewStore.isMakingCMix { ProgressView() } } } - if viewStore.hasStoredCmix { + if viewStore.hasStoredCMix { Button(role: .destructive) { - viewStore.send(.removeStoredCmix) + viewStore.send(.removeStoredCMix) } label: { HStack { Text("Remove stored cMix") Spacer() - if viewStore.isRemovingCmix { + if viewStore.isRemovingCMix { ProgressView() } } diff --git a/Example/example-app/Sources/SessionFeature/SessionFeature.swift b/Example/example-app/Sources/SessionFeature/SessionFeature.swift index a5bd6f9c..bdbc1015 100644 --- a/Example/example-app/Sources/SessionFeature/SessionFeature.swift +++ b/Example/example-app/Sources/SessionFeature/SessionFeature.swift @@ -37,18 +37,18 @@ public enum SessionAction: Equatable { public struct SessionEnvironment { public init( - getCmix: @escaping () -> Cmix?, + getCMix: @escaping () -> CMix?, bgScheduler: AnySchedulerOf<DispatchQueue>, mainScheduler: AnySchedulerOf<DispatchQueue>, error: ErrorEnvironment ) { - self.getCmix = getCmix + self.getCMix = getCMix self.bgScheduler = bgScheduler self.mainScheduler = mainScheduler self.error = error } - public var getCmix: () -> Cmix? + public var getCMix: () -> CMix? public var bgScheduler: AnySchedulerOf<DispatchQueue> public var mainScheduler: AnySchedulerOf<DispatchQueue> public var error: ErrorEnvironment @@ -65,7 +65,7 @@ public let sessionReducer = Reducer<SessionState, SessionAction, SessionEnvironm case .updateNetworkFollowerStatus: return Effect.future { fulfill in - let status = env.getCmix()?.networkFollowerStatus() + let status = env.getCMix()?.networkFollowerStatus() fulfill(.success(.didUpdateNetworkFollowerStatus(status))) } .subscribe(on: env.bgScheduler) @@ -80,14 +80,14 @@ public let sessionReducer = Reducer<SessionState, SessionAction, SessionEnvironm return Effect.run { subscriber in do { if start { - try env.getCmix()?.startNetworkFollower(timeoutMS: 30_000) + try env.getCMix()?.startNetworkFollower(timeoutMS: 30_000) } else { - try env.getCmix()?.stopNetworkFollower() + try env.getCMix()?.stopNetworkFollower() } } catch { subscriber.send(.networkFollowerDidFail(error as NSError)) } - let status = env.getCmix()?.networkFollowerStatus() + let status = env.getCMix()?.networkFollowerStatus() subscriber.send(.didUpdateNetworkFollowerStatus(status)) subscriber.send(completion: .finished) return AnyCancellable {} @@ -110,7 +110,7 @@ public let sessionReducer = Reducer<SessionState, SessionAction, SessionEnvironm let callback = HealthCallback { isHealthy in subscriber.send(.didUpdateNetworkHealth(isHealthy)) } - let cancellable = env.getCmix()?.addHealthCallback(callback) + let cancellable = env.getCMix()?.addHealthCallback(callback) return AnyCancellable { cancellable?.cancel() } @@ -147,7 +147,7 @@ public let sessionReducer = Reducer<SessionState, SessionAction, SessionEnvironm extension SessionEnvironment { public static let unimplemented = SessionEnvironment( - getCmix: XCTUnimplemented("\(Self.self).getCmix"), + getCMix: XCTUnimplemented("\(Self.self).getCMix"), bgScheduler: .unimplemented, mainScheduler: .unimplemented, error: .unimplemented diff --git a/Example/example-app/Tests/AppFeatureTests/AppFeatureTests.swift b/Example/example-app/Tests/AppFeatureTests/AppFeatureTests.swift index 24abccd8..d5cd1cef 100644 --- a/Example/example-app/Tests/AppFeatureTests/AppFeatureTests.swift +++ b/Example/example-app/Tests/AppFeatureTests/AppFeatureTests.swift @@ -8,7 +8,7 @@ import XCTest final class AppFeatureTests: XCTestCase { func testViewDidLoad() throws { let newId = UUID() - let hasCmix = PassthroughSubject<Bool, Never>() + let hasCMix = PassthroughSubject<Bool, Never>() let mainScheduler = DispatchQueue.test let store = TestStore( @@ -18,34 +18,34 @@ final class AppFeatureTests: XCTestCase { ) store.environment.makeId = { newId } - store.environment.hasCmix = { hasCmix.eraseToAnyPublisher() } + store.environment.hasCMix = { hasCMix.eraseToAnyPublisher() } store.environment.mainScheduler = mainScheduler.eraseToAnyScheduler() store.send(.viewDidLoad) - hasCmix.send(false) + hasCMix.send(false) mainScheduler.advance() - store.receive(.cmixDidChange(hasCmix: false)) + store.receive(.cMixDidChange(hasCMix: false)) - hasCmix.send(true) + hasCMix.send(true) mainScheduler.advance() - store.receive(.cmixDidChange(hasCmix: true)) { + store.receive(.cMixDidChange(hasCMix: true)) { $0.scene = .session(SessionState(id: newId)) } - hasCmix.send(true) + hasCMix.send(true) mainScheduler.advance() - hasCmix.send(false) + hasCMix.send(false) mainScheduler.advance() - store.receive(.cmixDidChange(hasCmix: false)) { + store.receive(.cMixDidChange(hasCMix: false)) { $0.scene = .landing(LandingState(id: newId)) } - hasCmix.send(completion: .finished) + hasCMix.send(completion: .finished) mainScheduler.advance() } } diff --git a/Example/example-app/Tests/LandingFeatureTests/LandingFeatureTests.swift b/Example/example-app/Tests/LandingFeatureTests/LandingFeatureTests.swift index cb52fb7b..9018641d 100644 --- a/Example/example-app/Tests/LandingFeatureTests/LandingFeatureTests.swift +++ b/Example/example-app/Tests/LandingFeatureTests/LandingFeatureTests.swift @@ -11,16 +11,16 @@ final class LandingFeatureTests: XCTestCase { environment: .unimplemented ) - store.environment.cmixManager.hasStorage.run = { true } + store.environment.cMixManager.hasStorage.run = { true } store.send(.viewDidLoad) { - $0.hasStoredCmix = true + $0.hasStoredCMix = true } } - func testCreateCmix() { - var hasStoredCmix = false - var didSetCmix = false + func testCreateCMix() { + var hasStoredCMix = false + var didSetCMix = false let bgScheduler = DispatchQueue.test let mainScheduler = DispatchQueue.test @@ -30,31 +30,31 @@ final class LandingFeatureTests: XCTestCase { environment: .unimplemented ) - store.environment.cmixManager.hasStorage.run = { hasStoredCmix } - store.environment.cmixManager.create.run = { .unimplemented } - store.environment.setCmix = { _ in didSetCmix = true } + store.environment.cMixManager.hasStorage.run = { hasStoredCMix } + store.environment.cMixManager.create.run = { .unimplemented } + store.environment.setCMix = { _ in didSetCMix = true } store.environment.bgScheduler = bgScheduler.eraseToAnyScheduler() store.environment.mainScheduler = mainScheduler.eraseToAnyScheduler() - store.send(.makeCmix) { - $0.isMakingCmix = true + store.send(.makeCMix) { + $0.isMakingCMix = true } bgScheduler.advance() - XCTAssertTrue(didSetCmix) + XCTAssertTrue(didSetCMix) - hasStoredCmix = true + hasStoredCMix = true mainScheduler.advance() - store.receive(.didMakeCmix) { - $0.isMakingCmix = false - $0.hasStoredCmix = true + store.receive(.didMakeCMix) { + $0.isMakingCMix = false + $0.hasStoredCMix = true } } - func testLoadStoredCmix() { - var didSetCmix = false + func testLoadStoredCMix() { + var didSetCMix = false let bgScheduler = DispatchQueue.test let mainScheduler = DispatchQueue.test @@ -64,29 +64,29 @@ final class LandingFeatureTests: XCTestCase { environment: .unimplemented ) - store.environment.cmixManager.hasStorage.run = { true } - store.environment.cmixManager.load.run = { .unimplemented } - store.environment.setCmix = { _ in didSetCmix = true } + store.environment.cMixManager.hasStorage.run = { true } + store.environment.cMixManager.load.run = { .unimplemented } + store.environment.setCMix = { _ in didSetCMix = true } store.environment.bgScheduler = bgScheduler.eraseToAnyScheduler() store.environment.mainScheduler = mainScheduler.eraseToAnyScheduler() - store.send(.makeCmix) { - $0.isMakingCmix = true + store.send(.makeCMix) { + $0.isMakingCMix = true } bgScheduler.advance() - XCTAssertTrue(didSetCmix) + XCTAssertTrue(didSetCMix) mainScheduler.advance() - store.receive(.didMakeCmix) { - $0.isMakingCmix = false - $0.hasStoredCmix = true + store.receive(.didMakeCMix) { + $0.isMakingCMix = false + $0.hasStoredCMix = true } } - func testMakeCmixFailure() { + func testMakeCMixFailure() { let error = NSError(domain: "test", code: 1234) let bgScheduler = DispatchQueue.test let mainScheduler = DispatchQueue.test @@ -97,28 +97,28 @@ final class LandingFeatureTests: XCTestCase { environment: .unimplemented ) - store.environment.cmixManager.hasStorage.run = { false } - store.environment.cmixManager.create.run = { throw error } + store.environment.cMixManager.hasStorage.run = { false } + store.environment.cMixManager.create.run = { throw error } store.environment.bgScheduler = bgScheduler.eraseToAnyScheduler() store.environment.mainScheduler = mainScheduler.eraseToAnyScheduler() - store.send(.makeCmix) { - $0.isMakingCmix = true + store.send(.makeCMix) { + $0.isMakingCMix = true } bgScheduler.advance() mainScheduler.advance() - store.receive(.didFailMakingCmix(error)) { - $0.isMakingCmix = false - $0.hasStoredCmix = false + store.receive(.didFailMakingCMix(error)) { + $0.isMakingCMix = false + $0.hasStoredCMix = false $0.error = ErrorState(error: error) } } - func testRemoveStoredCmix() { - var hasStoredCmix = true - var didRemoveCmix = false + func testRemoveStoredCMix() { + var hasStoredCMix = true + var didRemoveCMix = false let bgScheduler = DispatchQueue.test let mainScheduler = DispatchQueue.test @@ -128,29 +128,29 @@ final class LandingFeatureTests: XCTestCase { environment: .unimplemented ) - store.environment.cmixManager.hasStorage.run = { hasStoredCmix } - store.environment.cmixManager.remove.run = { didRemoveCmix = true } + store.environment.cMixManager.hasStorage.run = { hasStoredCMix } + store.environment.cMixManager.remove.run = { didRemoveCMix = true } store.environment.bgScheduler = bgScheduler.eraseToAnyScheduler() store.environment.mainScheduler = mainScheduler.eraseToAnyScheduler() - store.send(.removeStoredCmix) { - $0.isRemovingCmix = true + store.send(.removeStoredCMix) { + $0.isRemovingCMix = true } bgScheduler.advance() - XCTAssertTrue(didRemoveCmix) + XCTAssertTrue(didRemoveCMix) - hasStoredCmix = false + hasStoredCMix = false mainScheduler.advance() - store.receive(.didRemoveStoredCmix) { - $0.isRemovingCmix = false - $0.hasStoredCmix = false + store.receive(.didRemoveStoredCMix) { + $0.isRemovingCMix = false + $0.hasStoredCMix = false } } - func testRemoveStoredCmixFailure() { + func testRemoveStoredCMixFailure() { let error = NSError(domain: "test", code: 1234) let bgScheduler = DispatchQueue.test let mainScheduler = DispatchQueue.test @@ -161,21 +161,21 @@ final class LandingFeatureTests: XCTestCase { environment: .unimplemented ) - store.environment.cmixManager.hasStorage.run = { true } - store.environment.cmixManager.remove.run = { throw error } + store.environment.cMixManager.hasStorage.run = { true } + store.environment.cMixManager.remove.run = { throw error } store.environment.bgScheduler = bgScheduler.eraseToAnyScheduler() store.environment.mainScheduler = mainScheduler.eraseToAnyScheduler() - store.send(.removeStoredCmix) { - $0.isRemovingCmix = true + store.send(.removeStoredCMix) { + $0.isRemovingCMix = true } bgScheduler.advance() mainScheduler.advance() - store.receive(.didFailRemovingStoredCmix(error)) { - $0.isRemovingCmix = false - $0.hasStoredCmix = true + store.receive(.didFailRemovingStoredCMix(error)) { + $0.isRemovingCMix = false + $0.hasStoredCMix = true $0.error = ErrorState(error: error) } } diff --git a/Example/example-app/Tests/SessionFeatureTests/SessionFeatureTests.swift b/Example/example-app/Tests/SessionFeatureTests/SessionFeatureTests.swift index 2b3250c6..5d860648 100644 --- a/Example/example-app/Tests/SessionFeatureTests/SessionFeatureTests.swift +++ b/Example/example-app/Tests/SessionFeatureTests/SessionFeatureTests.swift @@ -19,17 +19,17 @@ final class SessionFeatureTests: XCTestCase { environment: .unimplemented ) - store.environment.getCmix = { - var cmix = Cmix.unimplemented - cmix.networkFollowerStatus.run = { networkFollowerStatus } - cmix.addHealthCallback.run = { callback in + store.environment.getCMix = { + var cMix = CMix.unimplemented + cMix.networkFollowerStatus.run = { networkFollowerStatus } + cMix.addHealthCallback.run = { callback in networkHealthCallback = callback didStartMonitoringNetworkHealth += 1 return Cancellable { didStopMonitoringNetworkHealth += 1 } } - return cmix + return cMix } store.environment.bgScheduler = bgScheduler.eraseToAnyScheduler() store.environment.mainScheduler = mainScheduler.eraseToAnyScheduler() @@ -80,19 +80,19 @@ final class SessionFeatureTests: XCTestCase { environment: .unimplemented ) - store.environment.getCmix = { - var cmix = Cmix.unimplemented - cmix.networkFollowerStatus.run = { networkFollowerStatus } - cmix.startNetworkFollower.run = { + store.environment.getCMix = { + var cMix = CMix.unimplemented + cMix.networkFollowerStatus.run = { networkFollowerStatus } + cMix.startNetworkFollower.run = { didStartNetworkFollowerWithTimeout.append($0) if let error = networkFollowerStartError { throw error } } - cmix.stopNetworkFollower.run = { + cMix.stopNetworkFollower.run = { didStopNetworkFollower += 1 } - return cmix + return cMix } store.environment.bgScheduler = bgScheduler.eraseToAnyScheduler() store.environment.mainScheduler = mainScheduler.eraseToAnyScheduler() diff --git a/Sources/ElixxirDAppsSDK/CMix/CMix.swift b/Sources/ElixxirDAppsSDK/CMix/CMix.swift new file mode 100644 index 00000000..3cc8d100 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/CMix.swift @@ -0,0 +1,58 @@ +import Bindings + +public struct CMix { + public var getId: CMixGetId + public var getReceptionRegistrationValidationSignature: CMixGetReceptionRegistrationValidationSignature + public var makeReceptionIdentity: CMixMakeReceptionIdentity + public var makeLegacyReceptionIdentity: CMixMakeLegacyReceptionIdentity + public var isHealthy: CMixIsHealthy + public var hasRunningProcesses: CMixHasRunningProcesses + public var networkFollowerStatus: CMixNetworkFollowerStatus + public var startNetworkFollower: CMixStartNetworkFollower + public var stopNetworkFollower: CMixStopNetworkFollower + public var waitForNetwork: CMixWaitForNetwork + public var registerClientErrorCallback: CMixRegisterClientErrorCallback + public var addHealthCallback: CMixAddHealthCallback + public var waitForMessageDelivery: CMixWaitForMessageDelivery + public var connect: CMixConnect +} + +extension CMix { + public static func live(_ bindingsCMix: BindingsCmix) -> CMix { + CMix( + getId: .live(bindingsCMix), + getReceptionRegistrationValidationSignature: .live(bindingsCMix), + makeReceptionIdentity: .live(bindingsCMix), + makeLegacyReceptionIdentity: .live(bindingsCMix), + isHealthy: .live(bindingsCMix), + hasRunningProcesses: .live(bindingsCMix), + networkFollowerStatus: .live(bindingsCMix), + startNetworkFollower: .live(bindingsCMix), + stopNetworkFollower: .live(bindingsCMix), + waitForNetwork: .live(bindingsCMix), + registerClientErrorCallback: .live(bindingsCMix), + addHealthCallback: .live(bindingsCMix), + waitForMessageDelivery: .live(bindingsCMix), + connect: .live(bindingsCMix) + ) + } +} + +extension CMix { + public static let unimplemented = CMix( + getId: .unimplemented, + getReceptionRegistrationValidationSignature: .unimplemented, + makeReceptionIdentity: .unimplemented, + makeLegacyReceptionIdentity: .unimplemented, + isHealthy: .unimplemented, + hasRunningProcesses: .unimplemented, + networkFollowerStatus: .unimplemented, + startNetworkFollower: .unimplemented, + stopNetworkFollower: .unimplemented, + waitForNetwork: .unimplemented, + registerClientErrorCallback: .unimplemented, + addHealthCallback: .unimplemented, + waitForMessageDelivery: .unimplemented, + connect: .unimplemented + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixAddHealthCallback.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixAddHealthCallback.swift similarity index 51% rename from Sources/ElixxirDAppsSDK/Cmix/Functors/CmixAddHealthCallback.swift rename to Sources/ElixxirDAppsSDK/CMix/Functors/CMixAddHealthCallback.swift index 1326c857..2ffe3f77 100644 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixAddHealthCallback.swift +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixAddHealthCallback.swift @@ -1,7 +1,7 @@ import Bindings import XCTestDynamicOverlay -public struct CmixAddHealthCallback { +public struct CMixAddHealthCallback { public var run: (HealthCallback) -> Cancellable public func callAsFunction(_ callback: HealthCallback) -> Cancellable { @@ -9,21 +9,21 @@ public struct CmixAddHealthCallback { } } -extension CmixAddHealthCallback { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixAddHealthCallback { - CmixAddHealthCallback { callback in - let id = bindingsCmix.add( +extension CMixAddHealthCallback { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixAddHealthCallback { + CMixAddHealthCallback { callback in + let id = bindingsCMix.add( callback.makeBindingsHealthCallback() ) return Cancellable { - bindingsCmix.removeHealthCallback(id) + bindingsCMix.removeHealthCallback(id) } } } } -extension CmixAddHealthCallback { - public static let unimplemented = CmixAddHealthCallback( +extension CMixAddHealthCallback { + public static let unimplemented = CMixAddHealthCallback( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixConnect.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixConnect.swift similarity index 67% rename from Sources/ElixxirDAppsSDK/Cmix/Functors/CmixConnect.swift rename to Sources/ElixxirDAppsSDK/CMix/Functors/CMixConnect.swift index ec795556..2a1164b0 100644 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixConnect.swift +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixConnect.swift @@ -1,7 +1,7 @@ import Bindings import XCTestDynamicOverlay -public struct CmixConnect { +public struct CMixConnect { public var run: (Bool, Int, Data, Data) throws -> Connection public func callAsFunction( @@ -14,17 +14,17 @@ public struct CmixConnect { } } -extension CmixConnect { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixConnect { - CmixConnect { withAuthentication, e2eId, recipientContact, e2eParamsJSON in +extension CMixConnect { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixConnect { + CMixConnect { withAuthentication, e2eId, recipientContact, e2eParamsJSON in if withAuthentication { - return .live(try bindingsCmix.connect( + return .live(try bindingsCMix.connect( withAuthentication: e2eId, recipientContact: recipientContact, e2eParamsJSON: e2eParamsJSON )) } else { - return .live(try bindingsCmix.connect( + return .live(try bindingsCMix.connect( e2eId, recipientContact: recipientContact, e2eParamsJSON: e2eParamsJSON @@ -34,8 +34,8 @@ extension CmixConnect { } } -extension CmixConnect { - public static let unimplemented = CmixConnect( +extension CMixConnect { + public static let unimplemented = CMixConnect( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixGetId.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixGetId.swift new file mode 100644 index 00000000..3fd4aa33 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixGetId.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixGetId { + public var run: () -> Int + + public func callAsFunction() -> Int { + run() + } +} + +extension CMixGetId { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixGetId { + CMixGetId(run: bindingsCMix.getID) + } +} + +extension CMixGetId { + public static let unimplemented = CMixGetId( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixGetReceptionRegistrationValidationSignature.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixGetReceptionRegistrationValidationSignature.swift new file mode 100644 index 00000000..2905d8cc --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixGetReceptionRegistrationValidationSignature.swift @@ -0,0 +1,27 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixGetReceptionRegistrationValidationSignature { + public var run: () -> Data + + public func callAsFunction() -> Data { + run() + } +} + +extension CMixGetReceptionRegistrationValidationSignature { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixGetReceptionRegistrationValidationSignature { + CMixGetReceptionRegistrationValidationSignature { + guard let data = bindingsCMix.getReceptionRegistrationValidationSignature() else { + fatalError("BindingsCmix.getReceptionRegistrationValidationSignature returned `nil`") + } + return data + } + } +} + +extension CMixGetReceptionRegistrationValidationSignature { + public static let unimplemented = CMixGetReceptionRegistrationValidationSignature( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixHasRunningProcesses.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixHasRunningProcesses.swift new file mode 100644 index 00000000..fc74e2d0 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixHasRunningProcesses.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixHasRunningProcesses { + public var run: () -> Bool + + public func callAsFunction() -> Bool { + run() + } +} + +extension CMixHasRunningProcesses { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixHasRunningProcesses { + CMixHasRunningProcesses(run: bindingsCMix.hasRunningProcessies) + } +} + +extension CMixHasRunningProcesses { + public static let unimplemented = CMixHasRunningProcesses( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixIsHealthy.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixIsHealthy.swift new file mode 100644 index 00000000..aef27503 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixIsHealthy.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixIsHealthy { + public var run: () -> Bool + + public func callAsFunction() -> Bool { + run() + } +} + +extension CMixIsHealthy { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixIsHealthy { + CMixIsHealthy(run: bindingsCMix.isHealthy) + } +} + +extension CMixIsHealthy { + public static let unimplemented = CMixIsHealthy( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixMakeLegacyReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixMakeLegacyReceptionIdentity.swift new file mode 100644 index 00000000..ee0c9ad6 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixMakeLegacyReceptionIdentity.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixMakeLegacyReceptionIdentity { + public var run: () throws -> ReceptionIdentity + + public func callAsFunction() throws -> ReceptionIdentity { + try run() + } +} + +extension CMixMakeLegacyReceptionIdentity { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixMakeLegacyReceptionIdentity { + CMixMakeLegacyReceptionIdentity { + let data = try bindingsCMix.makeLegacyReceptionIdentity() + return try ReceptionIdentity.decode(data) + } + } +} + +extension CMixMakeLegacyReceptionIdentity { + public static let unimplemented = CMixMakeLegacyReceptionIdentity( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixMakeReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixMakeReceptionIdentity.swift new file mode 100644 index 00000000..973812cf --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixMakeReceptionIdentity.swift @@ -0,0 +1,25 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixMakeReceptionIdentity { + public var run: () throws -> ReceptionIdentity + + public func callAsFunction() throws -> ReceptionIdentity { + try run() + } +} + +extension CMixMakeReceptionIdentity { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixMakeReceptionIdentity { + CMixMakeReceptionIdentity { + let data = try bindingsCMix.makeReceptionIdentity() + return try ReceptionIdentity.decode(data) + } + } +} + +extension CMixMakeReceptionIdentity { + public static let unimplemented = CMixMakeReceptionIdentity( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixNetworkFollowerStatus.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixNetworkFollowerStatus.swift new file mode 100644 index 00000000..bfa108f7 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixNetworkFollowerStatus.swift @@ -0,0 +1,26 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixNetworkFollowerStatus { + public var run: () -> NetworkFollowerStatus + + public func callAsFunction() -> NetworkFollowerStatus { + run() + } +} + +extension CMixNetworkFollowerStatus { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixNetworkFollowerStatus { + CMixNetworkFollowerStatus { + NetworkFollowerStatus( + rawValue: bindingsCMix.networkFollowerStatus() + ) + } + } +} + +extension CMixNetworkFollowerStatus { + public static let unimplemented = CMixNetworkFollowerStatus( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixRegisterClientErrorCallback.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixRegisterClientErrorCallback.swift new file mode 100644 index 00000000..d48f073b --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixRegisterClientErrorCallback.swift @@ -0,0 +1,28 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixRegisterClientErrorCallback { + public var run: (ClientErrorCallback) -> Void + + public func callAsFunction( + _ callback: ClientErrorCallback + ) { + run(callback) + } +} + +extension CMixRegisterClientErrorCallback { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixRegisterClientErrorCallback { + CMixRegisterClientErrorCallback { callback in + bindingsCMix.registerClientErrorCallback( + callback.makeBindingsClientError() + ) + } + } +} + +extension CMixRegisterClientErrorCallback { + public static let unimplemented = CMixRegisterClientErrorCallback( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixStartNetworkFollower.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixStartNetworkFollower.swift new file mode 100644 index 00000000..46b376ea --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixStartNetworkFollower.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixStartNetworkFollower { + public var run: (Int) throws -> Void + + public func callAsFunction(timeoutMS: Int) throws { + try run(timeoutMS) + } +} + +extension CMixStartNetworkFollower { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixStartNetworkFollower { + CMixStartNetworkFollower { timeoutMS in + try bindingsCMix.startNetworkFollower(timeoutMS) + } + } +} + +extension CMixStartNetworkFollower { + public static let unimplemented = CMixStartNetworkFollower( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CMix/Functors/CMixStopNetworkFollower.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixStopNetworkFollower.swift new file mode 100644 index 00000000..2876deb8 --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixStopNetworkFollower.swift @@ -0,0 +1,22 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixStopNetworkFollower { + public var run: () throws -> Void + + public func callAsFunction() throws { + try run() + } +} + +extension CMixStopNetworkFollower { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixStopNetworkFollower { + CMixStopNetworkFollower(run: bindingsCMix.stopNetworkFollower) + } +} + +extension CMixStopNetworkFollower { + public static let unimplemented = CMixStopNetworkFollower( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForMessageDelivery.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixWaitForMessageDelivery.swift similarity index 60% rename from Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForMessageDelivery.swift rename to Sources/ElixxirDAppsSDK/CMix/Functors/CMixWaitForMessageDelivery.swift index 967c517b..7649a1da 100644 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForMessageDelivery.swift +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixWaitForMessageDelivery.swift @@ -1,7 +1,7 @@ import Bindings import XCTestDynamicOverlay -public struct CmixWaitForMessageDelivery { +public struct CMixWaitForMessageDelivery { public var run: (E2ESendReport, Int, MessageDeliveryCallback) throws -> Void public func callAsFunction( @@ -13,10 +13,10 @@ public struct CmixWaitForMessageDelivery { } } -extension CmixWaitForMessageDelivery { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixWaitForMessageDelivery { - CmixWaitForMessageDelivery { report, timeoutMS, callback in - try bindingsCmix.wait( +extension CMixWaitForMessageDelivery { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixWaitForMessageDelivery { + CMixWaitForMessageDelivery { report, timeoutMS, callback in + try bindingsCMix.wait( forMessageDelivery: try report.encode(), mdc: callback.makeBindingsMessageDeliveryCallback(), timeoutMS: timeoutMS @@ -25,8 +25,8 @@ extension CmixWaitForMessageDelivery { } } -extension CmixWaitForMessageDelivery { - public static let unimplemented = CmixWaitForMessageDelivery( +extension CMixWaitForMessageDelivery { + public static let unimplemented = CMixWaitForMessageDelivery( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForNetwork.swift b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixWaitForNetwork.swift similarity index 57% rename from Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForNetwork.swift rename to Sources/ElixxirDAppsSDK/CMix/Functors/CMixWaitForNetwork.swift index 3174c69f..4e8a6292 100644 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixWaitForNetwork.swift +++ b/Sources/ElixxirDAppsSDK/CMix/Functors/CMixWaitForNetwork.swift @@ -1,7 +1,7 @@ import Bindings import XCTestDynamicOverlay -public struct CmixWaitForNetwork { +public struct CMixWaitForNetwork { public var run: (Int) -> Bool public func callAsFunction(timeoutMS: Int) -> Bool { @@ -9,14 +9,14 @@ public struct CmixWaitForNetwork { } } -extension CmixWaitForNetwork { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixWaitForNetwork { - CmixWaitForNetwork(run: bindingsCmix.wait(forNetwork:)) +extension CMixWaitForNetwork { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixWaitForNetwork { + CMixWaitForNetwork(run: bindingsCMix.wait(forNetwork:)) } } -extension CmixWaitForNetwork { - public static let unimplemented = CmixWaitForNetwork( +extension CMixWaitForNetwork { + public static let unimplemented = CMixWaitForNetwork( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/Cmix/Cmix.swift b/Sources/ElixxirDAppsSDK/Cmix/Cmix.swift deleted file mode 100644 index 3964f33b..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Cmix.swift +++ /dev/null @@ -1,58 +0,0 @@ -import Bindings - -public struct Cmix { - public var getId: CmixGetId - public var getReceptionRegistrationValidationSignature: CmixGetReceptionRegistrationValidationSignature - public var makeReceptionIdentity: CmixMakeReceptionIdentity - public var makeLegacyReceptionIdentity: CmixMakeLegacyReceptionIdentity - public var isHealthy: CmixIsHealthy - public var hasRunningProcesses: CmixHasRunningProcesses - public var networkFollowerStatus: CmixNetworkFollowerStatus - public var startNetworkFollower: CmixStartNetworkFollower - public var stopNetworkFollower: CmixStopNetworkFollower - public var waitForNetwork: CmixWaitForNetwork - public var registerClientErrorCallback: CmixRegisterClientErrorCallback - public var addHealthCallback: CmixAddHealthCallback - public var waitForMessageDelivery: CmixWaitForMessageDelivery - public var connect: CmixConnect -} - -extension Cmix { - public static func live(_ bindingsCmix: BindingsCmix) -> Cmix { - Cmix( - getId: .live(bindingsCmix), - getReceptionRegistrationValidationSignature: .live(bindingsCmix), - makeReceptionIdentity: .live(bindingsCmix), - makeLegacyReceptionIdentity: .live(bindingsCmix), - isHealthy: .live(bindingsCmix), - hasRunningProcesses: .live(bindingsCmix), - networkFollowerStatus: .live(bindingsCmix), - startNetworkFollower: .live(bindingsCmix), - stopNetworkFollower: .live(bindingsCmix), - waitForNetwork: .live(bindingsCmix), - registerClientErrorCallback: .live(bindingsCmix), - addHealthCallback: .live(bindingsCmix), - waitForMessageDelivery: .live(bindingsCmix), - connect: .live(bindingsCmix) - ) - } -} - -extension Cmix { - public static let unimplemented = Cmix( - getId: .unimplemented, - getReceptionRegistrationValidationSignature: .unimplemented, - makeReceptionIdentity: .unimplemented, - makeLegacyReceptionIdentity: .unimplemented, - isHealthy: .unimplemented, - hasRunningProcesses: .unimplemented, - networkFollowerStatus: .unimplemented, - startNetworkFollower: .unimplemented, - stopNetworkFollower: .unimplemented, - waitForNetwork: .unimplemented, - registerClientErrorCallback: .unimplemented, - addHealthCallback: .unimplemented, - waitForMessageDelivery: .unimplemented, - connect: .unimplemented - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetId.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetId.swift deleted file mode 100644 index 2d4a9255..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetId.swift +++ /dev/null @@ -1,22 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixGetId { - public var run: () -> Int - - public func callAsFunction() -> Int { - run() - } -} - -extension CmixGetId { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixGetId { - CmixGetId(run: bindingsCmix.getID) - } -} - -extension CmixGetId { - public static let unimplemented = CmixGetId( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetReceptionRegistrationValidationSignature.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetReceptionRegistrationValidationSignature.swift deleted file mode 100644 index 06303e2b..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixGetReceptionRegistrationValidationSignature.swift +++ /dev/null @@ -1,27 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixGetReceptionRegistrationValidationSignature { - public var run: () -> Data - - public func callAsFunction() -> Data { - run() - } -} - -extension CmixGetReceptionRegistrationValidationSignature { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixGetReceptionRegistrationValidationSignature { - CmixGetReceptionRegistrationValidationSignature { - guard let data = bindingsCmix.getReceptionRegistrationValidationSignature() else { - fatalError("BindingsCmix.getReceptionRegistrationValidationSignature returned `nil`") - } - return data - } - } -} - -extension CmixGetReceptionRegistrationValidationSignature { - public static let unimplemented = CmixGetReceptionRegistrationValidationSignature( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixHasRunningProcesses.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixHasRunningProcesses.swift deleted file mode 100644 index 0e83c257..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixHasRunningProcesses.swift +++ /dev/null @@ -1,22 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixHasRunningProcesses { - public var run: () -> Bool - - public func callAsFunction() -> Bool { - run() - } -} - -extension CmixHasRunningProcesses { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixHasRunningProcesses { - CmixHasRunningProcesses(run: bindingsCmix.hasRunningProcessies) - } -} - -extension CmixHasRunningProcesses { - public static let unimplemented = CmixHasRunningProcesses( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixIsHealthy.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixIsHealthy.swift deleted file mode 100644 index bdf89b84..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixIsHealthy.swift +++ /dev/null @@ -1,22 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixIsHealthy { - public var run: () -> Bool - - public func callAsFunction() -> Bool { - run() - } -} - -extension CmixIsHealthy { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixIsHealthy { - CmixIsHealthy(run: bindingsCmix.isHealthy) - } -} - -extension CmixIsHealthy { - public static let unimplemented = CmixIsHealthy( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeLegacyReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeLegacyReceptionIdentity.swift deleted file mode 100644 index 8ba84385..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeLegacyReceptionIdentity.swift +++ /dev/null @@ -1,25 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixMakeLegacyReceptionIdentity { - public var run: () throws -> ReceptionIdentity - - public func callAsFunction() throws -> ReceptionIdentity { - try run() - } -} - -extension CmixMakeLegacyReceptionIdentity { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixMakeLegacyReceptionIdentity { - CmixMakeLegacyReceptionIdentity { - let data = try bindingsCmix.makeLegacyReceptionIdentity() - return try ReceptionIdentity.decode(data) - } - } -} - -extension CmixMakeLegacyReceptionIdentity { - public static let unimplemented = CmixMakeLegacyReceptionIdentity( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeReceptionIdentity.swift deleted file mode 100644 index 67588e95..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixMakeReceptionIdentity.swift +++ /dev/null @@ -1,25 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixMakeReceptionIdentity { - public var run: () throws -> ReceptionIdentity - - public func callAsFunction() throws -> ReceptionIdentity { - try run() - } -} - -extension CmixMakeReceptionIdentity { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixMakeReceptionIdentity { - CmixMakeReceptionIdentity { - let data = try bindingsCmix.makeReceptionIdentity() - return try ReceptionIdentity.decode(data) - } - } -} - -extension CmixMakeReceptionIdentity { - public static let unimplemented = CmixMakeReceptionIdentity( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixNetworkFollowerStatus.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixNetworkFollowerStatus.swift deleted file mode 100644 index 53857634..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixNetworkFollowerStatus.swift +++ /dev/null @@ -1,26 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixNetworkFollowerStatus { - public var run: () -> NetworkFollowerStatus - - public func callAsFunction() -> NetworkFollowerStatus { - run() - } -} - -extension CmixNetworkFollowerStatus { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixNetworkFollowerStatus { - CmixNetworkFollowerStatus { - NetworkFollowerStatus( - rawValue: bindingsCmix.networkFollowerStatus() - ) - } - } -} - -extension CmixNetworkFollowerStatus { - public static let unimplemented = CmixNetworkFollowerStatus( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixRegisterClientErrorCallback.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixRegisterClientErrorCallback.swift deleted file mode 100644 index a8a56a8f..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixRegisterClientErrorCallback.swift +++ /dev/null @@ -1,28 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixRegisterClientErrorCallback { - public var run: (ClientErrorCallback) -> Void - - public func callAsFunction( - _ callback: ClientErrorCallback - ) { - run(callback) - } -} - -extension CmixRegisterClientErrorCallback { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixRegisterClientErrorCallback { - CmixRegisterClientErrorCallback { callback in - bindingsCmix.registerClientErrorCallback( - callback.makeBindingsClientError() - ) - } - } -} - -extension CmixRegisterClientErrorCallback { - public static let unimplemented = CmixRegisterClientErrorCallback( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStartNetworkFollower.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStartNetworkFollower.swift deleted file mode 100644 index 6e6a80a0..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStartNetworkFollower.swift +++ /dev/null @@ -1,24 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixStartNetworkFollower { - public var run: (Int) throws -> Void - - public func callAsFunction(timeoutMS: Int) throws { - try run(timeoutMS) - } -} - -extension CmixStartNetworkFollower { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixStartNetworkFollower { - CmixStartNetworkFollower { timeoutMS in - try bindingsCmix.startNetworkFollower(timeoutMS) - } - } -} - -extension CmixStartNetworkFollower { - public static let unimplemented = CmixStartNetworkFollower( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStopNetworkFollower.swift b/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStopNetworkFollower.swift deleted file mode 100644 index 140a415e..00000000 --- a/Sources/ElixxirDAppsSDK/Cmix/Functors/CmixStopNetworkFollower.swift +++ /dev/null @@ -1,22 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CmixStopNetworkFollower { - public var run: () throws -> Void - - public func callAsFunction() throws { - try run() - } -} - -extension CmixStopNetworkFollower { - public static func live(_ bindingsCmix: BindingsCmix) -> CmixStopNetworkFollower { - CmixStopNetworkFollower(run: bindingsCmix.stopNetworkFollower) - } -} - -extension CmixStopNetworkFollower { - public static let unimplemented = CmixStopNetworkFollower( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/CmixManager/CmixManager.swift b/Sources/ElixxirDAppsSDK/CmixManager/CMixManager.swift similarity index 66% rename from Sources/ElixxirDAppsSDK/CmixManager/CmixManager.swift rename to Sources/ElixxirDAppsSDK/CmixManager/CMixManager.swift index 6ab8edda..1763bb3e 100644 --- a/Sources/ElixxirDAppsSDK/CmixManager/CmixManager.swift +++ b/Sources/ElixxirDAppsSDK/CmixManager/CMixManager.swift @@ -1,13 +1,13 @@ import Bindings -public struct CmixManager { - public var hasStorage: CmixManagerHasStorage - public var create: CmixManagerCreate - public var load: CmixManagerLoad - public var remove: CmixManagerRemove +public struct CMixManager { + public var hasStorage: CMixManagerHasStorage + public var create: CMixManagerCreate + public var load: CMixManagerLoad + public var remove: CMixManagerRemove } -extension CmixManager { +extension CMixManager { public static func live( directoryPath: String = FileManager.default .urls(for: .applicationSupportDirectory, in: .userDomainMask) @@ -19,11 +19,11 @@ extension CmixManager { downloadNDF: DownloadAndVerifySignedNdf = .live, generateSecret: GenerateSecret = .live, passwordStorage: PasswordStorage, - newCmix: NewCmix = .live, - getCmixParams: GetCmixParams = .liveDefault, - loadCmix: LoadCmix = .live - ) -> CmixManager { - CmixManager( + newCMix: NewCMix = .live, + getCMixParams: GetCMixParams = .liveDefault, + loadCMix: LoadCMix = .live + ) -> CMixManager { + CMixManager( hasStorage: .live( directoryPath: directoryPath, fileManager: fileManager @@ -35,15 +35,15 @@ extension CmixManager { passwordStorage: passwordStorage, directoryPath: directoryPath, fileManager: fileManager, - newCmix: newCmix, - getCmixParams: getCmixParams, - loadCmix: loadCmix + newCMix: newCMix, + getCMixParams: getCMixParams, + loadCMix: loadCMix ), load: .live( directoryPath: directoryPath, passwordStorage: passwordStorage, - getCmixParams: getCmixParams, - loadCmix: loadCmix + getCMixParams: getCMixParams, + loadCMix: loadCMix ), remove: .live( directoryPath: directoryPath, @@ -53,8 +53,8 @@ extension CmixManager { } } -extension CmixManager { - public static let unimplemented = CmixManager( +extension CMixManager { + public static let unimplemented = CMixManager( hasStorage: .unimplemented, create: .unimplemented, load: .unimplemented, diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerCreate.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerCreate.swift similarity index 66% rename from Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerCreate.swift rename to Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerCreate.swift index 3c6e9838..b7f36cb1 100644 --- a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerCreate.swift +++ b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerCreate.swift @@ -1,15 +1,15 @@ import Foundation import XCTestDynamicOverlay -public struct CmixManagerCreate { - public var run: () throws -> Cmix +public struct CMixManagerCreate { + public var run: () throws -> CMix - public func callAsFunction() throws -> Cmix { + public func callAsFunction() throws -> CMix { try run() } } -extension CmixManagerCreate { +extension CMixManagerCreate { public static func live( environment: Environment, downloadNDF: DownloadAndVerifySignedNdf, @@ -17,33 +17,33 @@ extension CmixManagerCreate { passwordStorage: PasswordStorage, directoryPath: String, fileManager: FileManager, - newCmix: NewCmix, - getCmixParams: GetCmixParams, - loadCmix: LoadCmix - ) -> CmixManagerCreate { - CmixManagerCreate { + newCMix: NewCMix, + getCMixParams: GetCMixParams, + loadCMix: LoadCMix + ) -> CMixManagerCreate { + CMixManagerCreate { let ndfData = try downloadNDF(environment) let password = generateSecret() try passwordStorage.save(password) try? fileManager.removeItem(atPath: directoryPath) try? fileManager.createDirectory(atPath: directoryPath, withIntermediateDirectories: true) - try newCmix( + try newCMix( ndfJSON: String(data: ndfData, encoding: .utf8)!, storageDir: directoryPath, password: password, registrationCode: nil ) - return try loadCmix( + return try loadCMix( storageDir: directoryPath, password: password, - cmixParamsJSON: getCmixParams() + cMixParamsJSON: getCMixParams() ) } } } -extension CmixManagerCreate { - public static let unimplemented = CmixManagerCreate( +extension CMixManagerCreate { + public static let unimplemented = CMixManagerCreate( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerHasStorage.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerHasStorage.swift similarity index 65% rename from Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerHasStorage.swift rename to Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerHasStorage.swift index 29a2b559..0002353f 100644 --- a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerHasStorage.swift +++ b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerHasStorage.swift @@ -1,7 +1,7 @@ import Foundation import XCTestDynamicOverlay -public struct CmixManagerHasStorage { +public struct CMixManagerHasStorage { public var run: () -> Bool public func callAsFunction() -> Bool { @@ -9,20 +9,20 @@ public struct CmixManagerHasStorage { } } -extension CmixManagerHasStorage { +extension CMixManagerHasStorage { public static func live( directoryPath: String, fileManager: FileManager - ) -> CmixManagerHasStorage { - CmixManagerHasStorage { + ) -> CMixManagerHasStorage { + CMixManagerHasStorage { let contents = try? fileManager.contentsOfDirectory(atPath: directoryPath) return contents.map { $0.isEmpty == false } ?? false } } } -extension CmixManagerHasStorage { - public static let unimplemented = CmixManagerHasStorage( +extension CMixManagerHasStorage { + public static let unimplemented = CMixManagerHasStorage( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerLoad.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerLoad.swift new file mode 100644 index 00000000..fec08d8f --- /dev/null +++ b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerLoad.swift @@ -0,0 +1,32 @@ +import XCTestDynamicOverlay + +public struct CMixManagerLoad { + public var run: () throws -> CMix + + public func callAsFunction() throws -> CMix { + try run() + } +} + +extension CMixManagerLoad { + public static func live( + directoryPath: String, + passwordStorage: PasswordStorage, + getCMixParams: GetCMixParams, + loadCMix: LoadCMix + ) -> CMixManagerLoad { + CMixManagerLoad { + try loadCMix( + storageDir: directoryPath, + password: passwordStorage.load(), + cMixParamsJSON: getCMixParams() + ) + } + } +} + +extension CMixManagerLoad { + public static let unimplemented = CMixManagerLoad( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerRemove.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerRemove.swift similarity index 63% rename from Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerRemove.swift rename to Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerRemove.swift index e3c390ea..90027c43 100644 --- a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerRemove.swift +++ b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CMixManagerRemove.swift @@ -1,7 +1,7 @@ import Foundation import XCTestDynamicOverlay -public struct CmixManagerRemove { +public struct CMixManagerRemove { public var run: () throws -> Void public func callAsFunction() throws { @@ -9,19 +9,19 @@ public struct CmixManagerRemove { } } -extension CmixManagerRemove { +extension CMixManagerRemove { public static func live( directoryPath: String, fileManager: FileManager - ) -> CmixManagerRemove { - CmixManagerRemove { + ) -> CMixManagerRemove { + CMixManagerRemove { try fileManager.removeItem(atPath: directoryPath) } } } -extension CmixManagerRemove { - public static let unimplemented = CmixManagerRemove( +extension CMixManagerRemove { + public static let unimplemented = CMixManagerRemove( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerLoad.swift b/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerLoad.swift deleted file mode 100644 index 506cca47..00000000 --- a/Sources/ElixxirDAppsSDK/CmixManager/Functors/CmixManagerLoad.swift +++ /dev/null @@ -1,32 +0,0 @@ -import XCTestDynamicOverlay - -public struct CmixManagerLoad { - public var run: () throws -> Cmix - - public func callAsFunction() throws -> Cmix { - try run() - } -} - -extension CmixManagerLoad { - public static func live( - directoryPath: String, - passwordStorage: PasswordStorage, - getCmixParams: GetCmixParams, - loadCmix: LoadCmix - ) -> CmixManagerLoad { - CmixManagerLoad { - try loadCmix( - storageDir: directoryPath, - password: passwordStorage.load(), - cmixParamsJSON: getCmixParams() - ) - } - } -} - -extension CmixManagerLoad { - public static let unimplemented = CmixManagerLoad( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Functors/GetCmixParams.swift b/Sources/ElixxirDAppsSDK/Functors/GetCMixParams.swift similarity index 64% rename from Sources/ElixxirDAppsSDK/Functors/GetCmixParams.swift rename to Sources/ElixxirDAppsSDK/Functors/GetCMixParams.swift index 6cec08fe..0d47643f 100644 --- a/Sources/ElixxirDAppsSDK/Functors/GetCmixParams.swift +++ b/Sources/ElixxirDAppsSDK/Functors/GetCMixParams.swift @@ -1,7 +1,7 @@ import Bindings import XCTestDynamicOverlay -public struct GetCmixParams { +public struct GetCMixParams { public var run: () -> Data public func callAsFunction() -> Data { @@ -9,8 +9,8 @@ public struct GetCmixParams { } } -extension GetCmixParams { - public static let liveDefault = GetCmixParams { +extension GetCMixParams { + public static let liveDefault = GetCMixParams { guard let data = BindingsGetDefaultCMixParams() else { fatalError("BindingsGetDefaultCMixParams returned `nil`") } @@ -18,8 +18,8 @@ extension GetCmixParams { } } -extension GetCmixParams { - public static let unimplemented = GetCmixParams( +extension GetCMixParams { + public static let unimplemented = GetCMixParams( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/Functors/GetFileTransferParams.swift b/Sources/ElixxirDAppsSDK/Functors/GetFileTransferParams.swift index e7f04545..ab76a478 100644 --- a/Sources/ElixxirDAppsSDK/Functors/GetFileTransferParams.swift +++ b/Sources/ElixxirDAppsSDK/Functors/GetFileTransferParams.swift @@ -19,7 +19,7 @@ extension GetFileTransferParams { } extension GetFileTransferParams { - public static let unimplemented = GetCmixParams( + public static let unimplemented = GetCMixParams( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/Functors/GetSingleUseParams.swift b/Sources/ElixxirDAppsSDK/Functors/GetSingleUseParams.swift index 2b296b31..7fe87852 100644 --- a/Sources/ElixxirDAppsSDK/Functors/GetSingleUseParams.swift +++ b/Sources/ElixxirDAppsSDK/Functors/GetSingleUseParams.swift @@ -19,7 +19,7 @@ extension GetSingleUseParams { } extension GetSingleUseParams { - public static let unimplemented = GetCmixParams( + public static let unimplemented = GetCMixParams( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/Functors/LoadCMix.swift b/Sources/ElixxirDAppsSDK/Functors/LoadCMix.swift new file mode 100644 index 00000000..8c38481c --- /dev/null +++ b/Sources/ElixxirDAppsSDK/Functors/LoadCMix.swift @@ -0,0 +1,34 @@ +import Bindings +import XCTestDynamicOverlay + +public struct LoadCMix { + public var run: (String, Data, Data) throws -> CMix + + public func callAsFunction( + storageDir: String, + password: Data, + cMixParamsJSON: Data + ) throws -> CMix { + try run(storageDir, password, cMixParamsJSON) + } +} + +extension LoadCMix { + public static let live = LoadCMix { storageDir, password, cMixParamsJSON in + var error: NSError? + let bindingsCMix = BindingsLoadCmix(storageDir, password, cMixParamsJSON, &error) + if let error = error { + throw error + } + guard let bindingsCMix = bindingsCMix else { + fatalError("BindingsLoadCMix returned `nil` without providing error") + } + return CMix.live(bindingsCMix) + } +} + +extension LoadCMix { + public static let unimplemented = LoadCMix( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/ElixxirDAppsSDK/Functors/LoadCmix.swift b/Sources/ElixxirDAppsSDK/Functors/LoadCmix.swift deleted file mode 100644 index c388e9a3..00000000 --- a/Sources/ElixxirDAppsSDK/Functors/LoadCmix.swift +++ /dev/null @@ -1,34 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct LoadCmix { - public var run: (String, Data, Data) throws -> Cmix - - public func callAsFunction( - storageDir: String, - password: Data, - cmixParamsJSON: Data - ) throws -> Cmix { - try run(storageDir, password, cmixParamsJSON) - } -} - -extension LoadCmix { - public static let live = LoadCmix { storageDir, password, cmixParamsJSON in - var error: NSError? - let bindingsCmix = BindingsLoadCmix(storageDir, password, cmixParamsJSON, &error) - if let error = error { - throw error - } - guard let bindingsCmix = bindingsCmix else { - fatalError("BindingsLoadCmix returned `nil` without providing error") - } - return Cmix.live(bindingsCmix) - } -} - -extension LoadCmix { - public static let unimplemented = LoadCmix( - run: XCTUnimplemented("\(Self.self)") - ) -} diff --git a/Sources/ElixxirDAppsSDK/Functors/LoadReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Functors/LoadReceptionIdentity.swift index 64506348..4c0a1ac2 100644 --- a/Sources/ElixxirDAppsSDK/Functors/LoadReceptionIdentity.swift +++ b/Sources/ElixxirDAppsSDK/Functors/LoadReceptionIdentity.swift @@ -6,16 +6,16 @@ public struct LoadReceptionIdentity { public func callAsFunction( key: String, - cmixId: Int + cMixId: Int ) throws -> ReceptionIdentity { - try run(key, cmixId) + try run(key, cMixId) } } extension LoadReceptionIdentity { - public static let live = LoadReceptionIdentity { key, cmixId in + public static let live = LoadReceptionIdentity { key, cMixId in var error: NSError? - let data = BindingsLoadReceptionIdentity(key, cmixId, &error) + let data = BindingsLoadReceptionIdentity(key, cMixId, &error) if let error = error { throw error } diff --git a/Sources/ElixxirDAppsSDK/Functors/Login.swift b/Sources/ElixxirDAppsSDK/Functors/Login.swift index 574ce7a2..82a5b3a7 100644 --- a/Sources/ElixxirDAppsSDK/Functors/Login.swift +++ b/Sources/ElixxirDAppsSDK/Functors/Login.swift @@ -6,22 +6,22 @@ public struct Login { public func callAsFunction( ephemeral: Bool = false, - cmixId: Int, + cMixId: Int, authCallbacks: AuthCallbacks? = nil, identity: ReceptionIdentity, e2eParamsJSON: Data ) throws -> E2E { - try run(ephemeral, cmixId, authCallbacks, identity, e2eParamsJSON) + try run(ephemeral, cMixId, authCallbacks, identity, e2eParamsJSON) } } extension Login { - public static let live = Login { ephemeral, cmixId, authCallbacks, identity, e2eParamsJSON in + public static let live = Login { ephemeral, cMixId, authCallbacks, identity, e2eParamsJSON in var error: NSError? let bindingsE2E: BindingsE2e? if ephemeral { bindingsE2E = BindingsLogin( - cmixId, + cMixId, authCallbacks?.makeBindingsAuthCallbacks(), try identity.encode(), e2eParamsJSON, @@ -29,7 +29,7 @@ extension Login { ) } else { bindingsE2E = BindingsLoginEphemeral( - cmixId, + cMixId, authCallbacks?.makeBindingsAuthCallbacks(), try identity.encode(), e2eParamsJSON, diff --git a/Sources/ElixxirDAppsSDK/Functors/NewBroadcastChannel.swift b/Sources/ElixxirDAppsSDK/Functors/NewBroadcastChannel.swift index 11e519fa..0204cf1f 100644 --- a/Sources/ElixxirDAppsSDK/Functors/NewBroadcastChannel.swift +++ b/Sources/ElixxirDAppsSDK/Functors/NewBroadcastChannel.swift @@ -5,18 +5,18 @@ public struct NewBroadcastChannel { public var run: (Int, ChannelDef) throws -> Channel public func callAsFunction( - cmixId: Int, + cMixId: Int, channelDef: ChannelDef ) throws -> Channel { - try run(cmixId, channelDef) + try run(cMixId, channelDef) } } extension NewBroadcastChannel { - public static let live = NewBroadcastChannel { cmixId, channelDef in + public static let live = NewBroadcastChannel { cMixId, channelDef in var error: NSError? let bindingsChannel = BindingsNewBroadcastChannel( - cmixId, + cMixId, try channelDef.encode(), &error ) diff --git a/Sources/ElixxirDAppsSDK/Functors/NewCmix.swift b/Sources/ElixxirDAppsSDK/Functors/NewCMix.swift similarity index 71% rename from Sources/ElixxirDAppsSDK/Functors/NewCmix.swift rename to Sources/ElixxirDAppsSDK/Functors/NewCMix.swift index 4f906a46..1bfc41a4 100644 --- a/Sources/ElixxirDAppsSDK/Functors/NewCmix.swift +++ b/Sources/ElixxirDAppsSDK/Functors/NewCMix.swift @@ -1,7 +1,7 @@ import Bindings import XCTestDynamicOverlay -public struct NewCmix { +public struct NewCMix { public var run: (String, String, Data, String?) throws -> Void public func callAsFunction( @@ -14,21 +14,21 @@ public struct NewCmix { } } -extension NewCmix { - public static let live = NewCmix { ndfJSON, storageDir, password, registrationCode in +extension NewCMix { + public static let live = NewCMix { ndfJSON, storageDir, password, registrationCode in var error: NSError? let result = BindingsNewCmix(ndfJSON, storageDir, password, registrationCode, &error) if let error = error { throw error } if !result { - fatalError("BindingsNewCmix returned `false` without providing error") + fatalError("BindingsNewCMix returned `false` without providing error") } } } -extension NewCmix { - public static let unimplemented = NewCmix( +extension NewCMix { + public static let unimplemented = NewCMix( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/Functors/NewCmixFromBackup.swift b/Sources/ElixxirDAppsSDK/Functors/NewCMixFromBackup.swift similarity index 77% rename from Sources/ElixxirDAppsSDK/Functors/NewCmixFromBackup.swift rename to Sources/ElixxirDAppsSDK/Functors/NewCMixFromBackup.swift index 10e3e2c5..1a0fb013 100644 --- a/Sources/ElixxirDAppsSDK/Functors/NewCmixFromBackup.swift +++ b/Sources/ElixxirDAppsSDK/Functors/NewCMixFromBackup.swift @@ -1,7 +1,7 @@ import Bindings import XCTestDynamicOverlay -public struct NewCmixFromBackup { +public struct NewCMixFromBackup { public var run: (String, String, String, Data, Data) throws -> BackupReport public func callAsFunction( @@ -15,8 +15,8 @@ public struct NewCmixFromBackup { } } -extension NewCmixFromBackup { - public static let live = NewCmixFromBackup { +extension NewCMixFromBackup { + public static let live = NewCMixFromBackup { ndfJSON, storageDir, backupPassphrase, sessionPassword, backupFileContents in var error: NSError? @@ -32,14 +32,14 @@ extension NewCmixFromBackup { throw error } guard let reportData = reportData else { - fatalError("BindingsNewCmixFromBackup returned `nil` without providing error") + fatalError("BindingsNewCMixFromBackup returned `nil` without providing error") } return try BackupReport.decode(reportData) } } -extension NewCmixFromBackup { - public static let unimplemented = NewCmixFromBackup( +extension NewCMixFromBackup { + public static let unimplemented = NewCMixFromBackup( run: XCTUnimplemented("\(Self.self)") ) } diff --git a/Sources/ElixxirDAppsSDK/Functors/StoreReceptionIdentity.swift b/Sources/ElixxirDAppsSDK/Functors/StoreReceptionIdentity.swift index 5752bd5d..59e6281f 100644 --- a/Sources/ElixxirDAppsSDK/Functors/StoreReceptionIdentity.swift +++ b/Sources/ElixxirDAppsSDK/Functors/StoreReceptionIdentity.swift @@ -7,17 +7,17 @@ public struct StoreReceptionIdentity { public func callAsFunction( key: String, identity: ReceptionIdentity, - cmixId: Int + cMixId: Int ) throws -> Bool { - try run(key, identity, cmixId) + try run(key, identity, cMixId) } } extension StoreReceptionIdentity { - public static let live = StoreReceptionIdentity { key, identity, cmixId in + public static let live = StoreReceptionIdentity { key, identity, cMixId in var error: NSError? let identityData = try identity.encode() - let result = BindingsStoreReceptionIdentity(key, identityData, cmixId, &error) + let result = BindingsStoreReceptionIdentity(key, identityData, cMixId, &error) if let error = error { throw error } -- GitLab