diff --git a/Example/example-app/Sources/AppFeature/App.swift b/Example/example-app/Sources/AppFeature/App.swift index 2ad3db435adb6e6ee674b09f5d8878cb4d8bea6e..3392af19e09a8f7e68bc6341a049bc34bca9b83c 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 f9ce028759020d50a8853ebc55aff84530e0a710..3f521a128c499b8fb0d6ffaf0ae23d26344b202e 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 f8fa2d9db3a439f112d2b47edd39914d587f1b37..8de2eb3316acf58cef8f11699def99ccf1604c01 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 f52aeebb80bc75f503060b642ffaf97b9c843f27..e6903c2e957a9c40913b5f3635824fa43ef93ef5 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 a5bd6f9cb07099ea08483bed50941b371566f59f..bdbc1015fe0c0030eaed30b3416677e2521178bc 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 24abccd89477d96029c36a768a735d5f3bc59828..d5cd1cef41315d31db675122547d3f1f55d83525 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 cb52fb7b3b50c0e1cf39d8e6af5e509c1988686b..9018641dbf895d99919c8234600d304a65d8f0ce 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 2b3250c6b0b2db94c409cdf60804da306b12b4b4..5d860648ab0b6d80eb8451ebb8b203d3da959088 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 0000000000000000000000000000000000000000..3cc8d100128fe258bd4746410f098856dd7aa5ec --- /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 1326c85700ced8ae5b34b48bf87e17c7d91f67c9..2ffe3f77ad36b92bb45efef944f1440c9956410e 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 ec795556f60bf877893c3eaf903708948745934c..2a1164b0458ad711da205286281a76762e501252 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 0000000000000000000000000000000000000000..3fd4aa333f3b4566ca47cd6593d2ed69dc20b795 --- /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 0000000000000000000000000000000000000000..2905d8ccb4cfa37577f3e97637b3ada330d61c13 --- /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 0000000000000000000000000000000000000000..fc74e2d010c10fae8e71553835b3c7993cbf1f16 --- /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 0000000000000000000000000000000000000000..aef2750355e2ebfce955528fbf5c591e8558f97a --- /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 0000000000000000000000000000000000000000..ee0c9ad6ce866e5605b531a6c38d748f4d575d9a --- /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 0000000000000000000000000000000000000000..973812cf8cc77ea2ecadfd2cc18ff2c4a19ce6c4 --- /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 0000000000000000000000000000000000000000..bfa108f79a634668c1a1ab66346967f68c8888d2 --- /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 0000000000000000000000000000000000000000..d48f073b3a31a42af986c01c3ebcf993d69d5118 --- /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 0000000000000000000000000000000000000000..46b376ea40051ee2e5e91022c4528aba44877f46 --- /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 0000000000000000000000000000000000000000..2876deb8272367a5d1270267022d0e275fca13bd --- /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 967c517ba71735f9634e9544c3dd2cb9574d7574..7649a1da784a5fdb2b499ca53d7ae61ffb125c7c 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 3174c69f0750e8c19ddc5330354e1682909c8a17..4e8a62923af1c590fb5163251b97ab8d004b318b 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 3964f33b488554a58dfdf07478bbad8cc5d0eba5..0000000000000000000000000000000000000000 --- 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 2d4a925562bd69e87f97124a043b86296e79b123..0000000000000000000000000000000000000000 --- 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 06303e2b03ac9acdbaf88decf9530c51a5f86051..0000000000000000000000000000000000000000 --- 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 0e83c257e4b41aba08e97599f6a52ff7d462b60a..0000000000000000000000000000000000000000 --- 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 bdf89b846172f14f34bf10c5aaee18e5b1da5af1..0000000000000000000000000000000000000000 --- 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 8ba84385b806e193ad3f1eff0058aace33b5b28f..0000000000000000000000000000000000000000 --- 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 67588e9571ec07818bf4d7a4ced8b7955d5e5be6..0000000000000000000000000000000000000000 --- 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 53857634ab759436b0c243f1972b1a789f33bf8e..0000000000000000000000000000000000000000 --- 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 a8a56a8f402eb4f8d9efe7d4ca1aca8972c76367..0000000000000000000000000000000000000000 --- 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 6e6a80a0efc7c2f07d15ea05680e395e0f976f39..0000000000000000000000000000000000000000 --- 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 140a415ee5f2a7894387f8227835eae34d7e2cb0..0000000000000000000000000000000000000000 --- 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 6ab8eddad5c12bc61862e45536ca21b7e8cc5951..1763bb3e5e2d4e184add186d67a69ac6c93124f1 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 3c6e983871106b5dab33db0f8fb031ea91a594fa..b7f36cb127d777ca9cd3d7e3c85d576d25a7e54d 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 29a2b559d2293742a8d188815429ec81a4a33b80..0002353ffb6b731ed18b19db6ab66fcf09dd1fec 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 0000000000000000000000000000000000000000..fec08d8f96daa98b9edafd962b6f00b541da6678 --- /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 e3c390ea66cf98bf91ad660d969153fa885a4c12..90027c43643d52034e3a3d741e7a3d84571dd95e 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 506cca47cd901a22706366ecc850721c9594e77c..0000000000000000000000000000000000000000 --- 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 6cec08fedf48901971c1f9828226ff898da0a045..0d47643f00437f5a8d0f51c7fac56ab2b75d522d 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 e7f04545bc0c31e535363a32ec5ecc964eedb806..ab76a478422fde4317cab0637d4ab12d990b2de1 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 2b296b3113c25fc138043bb20a4b06828bd2b948..7fe87852cf89c70eafffde91cb3916935f9cd89c 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 0000000000000000000000000000000000000000..8c38481c405908148eebecff880862dfc64eaed4 --- /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 c388e9a333fd6f055f0bda7282309b34e0e66043..0000000000000000000000000000000000000000 --- 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 64506348055577f07abf71e97c82a715d05827fb..4c0a1ac26c01d956a8b61a8fd520f652762f0a27 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 574ce7a2806bda20462afca3a5a578ee25f0a4dc..82a5b3a7108b7265fac7ec0202fd1b4458927bb6 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 11e519fa41f0cc38d067e5d494c0b8dd911bb279..0204cf1f4f3da40b39f100e9857946846a6a7be6 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 4f906a46accc4b9bafd80bfc3fbe3780e589a85c..1bfc41a4ac797be9b7c77919ba4bf849b7927ea9 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 10e3e2c559976a336bb9e997cac532e2ab87eae1..1a0fb0133669fb0f101e103b46470d7024a5e097 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 5752bd5d91884b12b71ac6be812346b8d0e21fcb..59e6281fcdbe878a04b54c7c1416f05ea0344e84 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 }