From 3ab459773df42d4700b10e14319bd4539327649b Mon Sep 17 00:00:00 2001 From: Julian Locke Date: Fri, 23 Aug 2024 16:13:17 -0400 Subject: [PATCH 1/5] Generate reconnection helpers including route namespaces. --- .../AppAuthReconnectionHelpers.swift | 9 +- .../Generated/DropboxAppBaseRequestBox.swift | 6 +- .../Generated/DropboxBaseRequestBox.swift | 108 +++++++++--------- .../Generated/ReconnectionHelpers.swift | 77 +++++++------ .../Handwritten/DropboxTransportClient.swift | 3 +- .../Shared/Handwritten/MockApiRequest.swift | 2 +- .../ReconnectionHelpers+Handwritten.swift | 10 +- .../Handwritten/Request+TokenRefresh.swift | 12 +- .../DBXDropboxAppBaseRequestBox.swift | 2 +- .../Generated/DBXDropboxBaseRequestBox.swift | 36 +++--- .../ReconnectionHelperRouteNameTests.swift | 47 ++++++-- .../TestMockingUtilities.swift | 2 +- stone | 2 +- 13 files changed, 181 insertions(+), 135 deletions(-) diff --git a/Source/SwiftyDropbox/Shared/Generated/AppAuthReconnectionHelpers.swift b/Source/SwiftyDropbox/Shared/Generated/AppAuthReconnectionHelpers.swift index 024df54c..05048a21 100644 --- a/Source/SwiftyDropbox/Shared/Generated/AppAuthReconnectionHelpers.swift +++ b/Source/SwiftyDropbox/Shared/Generated/AppAuthReconnectionHelpers.swift @@ -4,13 +4,16 @@ import Foundation +// The case string below must match those created by ReconnectionHelpers+Handwritten.swift using +// the route name and namespace as formatted for the generated `Route` object in SwiftTypes.jinja +// Format: "/" e.g., "files/upload_session/append_v2" for Files.uploadSessionAppendV2 enum AppAuthReconnectionHelpers: ReconnectionHelpersShared { static func rebuildRequest(apiRequest: ApiRequest, client: DropboxTransportClientInternal) throws -> DropboxAppBaseRequestBox { let info = try persistedRequestInfo(from: apiRequest) - switch info.routeName { - case "get_thumbnail_v2": - return .getThumbnailV2( + switch info.namespaceRouteName { + case "files/get_thumbnail_v2": + return .files_getThumbnailV2( rebuildRequest( apiRequest: apiRequest, info: info, diff --git a/Source/SwiftyDropbox/Shared/Generated/DropboxAppBaseRequestBox.swift b/Source/SwiftyDropbox/Shared/Generated/DropboxAppBaseRequestBox.swift index 27181274..baabd57b 100644 --- a/Source/SwiftyDropbox/Shared/Generated/DropboxAppBaseRequestBox.swift +++ b/Source/SwiftyDropbox/Shared/Generated/DropboxAppBaseRequestBox.swift @@ -8,12 +8,12 @@ import Foundation /// Allows for heterogenous collections of typed requests public enum DropboxAppBaseRequestBox: CustomStringConvertible { - case getThumbnailV2(DownloadRequestFile) + case files_getThumbnailV2(DownloadRequestFile) public var description: String { switch self { - case .getThumbnailV2: - return "getThumbnailV2" + case .files_getThumbnailV2: + return "files/get_thumbnail_v2" } } } \ No newline at end of file diff --git a/Source/SwiftyDropbox/Shared/Generated/DropboxBaseRequestBox.swift b/Source/SwiftyDropbox/Shared/Generated/DropboxBaseRequestBox.swift index 9cc3ab82..32a0223f 100644 --- a/Source/SwiftyDropbox/Shared/Generated/DropboxBaseRequestBox.swift +++ b/Source/SwiftyDropbox/Shared/Generated/DropboxBaseRequestBox.swift @@ -8,63 +8,63 @@ import Foundation /// Allows for heterogenous collections of typed requests public enum DropboxBaseRequestBox: CustomStringConvertible { - case alphaUpload(UploadRequest) - case download(DownloadRequestFile) - case downloadZip(DownloadRequestFile) - case export(DownloadRequestFile) - case getPreview(DownloadRequestFile) - case getThumbnail(DownloadRequestFile) - case getThumbnailV2(DownloadRequestFile) - case paperCreate(UploadRequest) - case paperUpdate(UploadRequest) - case upload(UploadRequest) - case uploadSessionAppendV2(UploadRequest) - case uploadSessionAppend(UploadRequest) - case uploadSessionFinish(UploadRequest) - case uploadSessionStart(UploadRequest) - case docsCreate(UploadRequest) - case docsDownload(DownloadRequestFile) - case docsUpdate(UploadRequest) - case getSharedLinkFile(DownloadRequestFile) + case files_alphaUpload(UploadRequest) + case files_download(DownloadRequestFile) + case files_downloadZip(DownloadRequestFile) + case files_export(DownloadRequestFile) + case files_getPreview(DownloadRequestFile) + case files_getThumbnail(DownloadRequestFile) + case files_getThumbnailV2(DownloadRequestFile) + case files_paperCreate(UploadRequest) + case files_paperUpdate(UploadRequest) + case files_upload(UploadRequest) + case files_uploadSessionAppendV2(UploadRequest) + case files_uploadSessionAppend(UploadRequest) + case files_uploadSessionFinish(UploadRequest) + case files_uploadSessionStart(UploadRequest) + case paper_docsCreate(UploadRequest) + case paper_docsDownload(DownloadRequestFile) + case paper_docsUpdate(UploadRequest) + case sharing_getSharedLinkFile(DownloadRequestFile) public var description: String { switch self { - case .alphaUpload: - return "alphaUpload" - case .download: - return "download" - case .downloadZip: - return "downloadZip" - case .export: - return "export" - case .getPreview: - return "getPreview" - case .getThumbnail: - return "getThumbnail" - case .getThumbnailV2: - return "getThumbnailV2" - case .paperCreate: - return "paperCreate" - case .paperUpdate: - return "paperUpdate" - case .upload: - return "upload" - case .uploadSessionAppendV2: - return "uploadSessionAppendV2" - case .uploadSessionAppend: - return "uploadSessionAppend" - case .uploadSessionFinish: - return "uploadSessionFinish" - case .uploadSessionStart: - return "uploadSessionStart" - case .docsCreate: - return "docsCreate" - case .docsDownload: - return "docsDownload" - case .docsUpdate: - return "docsUpdate" - case .getSharedLinkFile: - return "getSharedLinkFile" + case .files_alphaUpload: + return "files/alpha/upload" + case .files_download: + return "files/download" + case .files_downloadZip: + return "files/download_zip" + case .files_export: + return "files/export" + case .files_getPreview: + return "files/get_preview" + case .files_getThumbnail: + return "files/get_thumbnail" + case .files_getThumbnailV2: + return "files/get_thumbnail_v2" + case .files_paperCreate: + return "files/paper/create" + case .files_paperUpdate: + return "files/paper/update" + case .files_upload: + return "files/upload" + case .files_uploadSessionAppendV2: + return "files/upload_session/append_v2" + case .files_uploadSessionAppend: + return "files/upload_session/append" + case .files_uploadSessionFinish: + return "files/upload_session/finish" + case .files_uploadSessionStart: + return "files/upload_session/start" + case .paper_docsCreate: + return "paper/docs/create" + case .paper_docsDownload: + return "paper/docs/download" + case .paper_docsUpdate: + return "paper/docs/update" + case .sharing_getSharedLinkFile: + return "sharing/get_shared_link_file" } } } \ No newline at end of file diff --git a/Source/SwiftyDropbox/Shared/Generated/ReconnectionHelpers.swift b/Source/SwiftyDropbox/Shared/Generated/ReconnectionHelpers.swift index 806a20c0..837003f4 100644 --- a/Source/SwiftyDropbox/Shared/Generated/ReconnectionHelpers.swift +++ b/Source/SwiftyDropbox/Shared/Generated/ReconnectionHelpers.swift @@ -4,13 +4,16 @@ import Foundation +// The case string below must match those created by ReconnectionHelpers+Handwritten.swift using +// the route name and namespace as formatted for the generated `Route` object in SwiftTypes.jinja +// Format: "/" e.g., "files/upload_session/append_v2" for Files.uploadSessionAppendV2 enum ReconnectionHelpers: ReconnectionHelpersShared { static func rebuildRequest(apiRequest: ApiRequest, client: DropboxTransportClientInternal) throws -> DropboxBaseRequestBox { let info = try persistedRequestInfo(from: apiRequest) - switch info.routeName { - case "alpha/upload": - return .alphaUpload( + switch info.namespaceRouteName { + case "files/alpha/upload": + return .files_alphaUpload( rebuildRequest( apiRequest: apiRequest, info: info, @@ -18,8 +21,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "download": - return .download( + case "files/download": + return .files_download( rebuildRequest( apiRequest: apiRequest, info: info, @@ -27,8 +30,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "download_zip": - return .downloadZip( + case "files/download_zip": + return .files_downloadZip( rebuildRequest( apiRequest: apiRequest, info: info, @@ -36,8 +39,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "export": - return .export( + case "files/export": + return .files_export( rebuildRequest( apiRequest: apiRequest, info: info, @@ -45,8 +48,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "get_preview": - return .getPreview( + case "files/get_preview": + return .files_getPreview( rebuildRequest( apiRequest: apiRequest, info: info, @@ -54,8 +57,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "get_thumbnail": - return .getThumbnail( + case "files/get_thumbnail": + return .files_getThumbnail( rebuildRequest( apiRequest: apiRequest, info: info, @@ -63,8 +66,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "get_thumbnail_v2": - return .getThumbnailV2( + case "files/get_thumbnail_v2": + return .files_getThumbnailV2( rebuildRequest( apiRequest: apiRequest, info: info, @@ -72,8 +75,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "paper/create": - return .paperCreate( + case "files/paper/create": + return .files_paperCreate( rebuildRequest( apiRequest: apiRequest, info: info, @@ -81,8 +84,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "paper/update": - return .paperUpdate( + case "files/paper/update": + return .files_paperUpdate( rebuildRequest( apiRequest: apiRequest, info: info, @@ -90,8 +93,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "upload": - return .upload( + case "files/upload": + return .files_upload( rebuildRequest( apiRequest: apiRequest, info: info, @@ -99,8 +102,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "upload_session/append_v2": - return .uploadSessionAppendV2( + case "files/upload_session/append_v2": + return .files_uploadSessionAppendV2( rebuildRequest( apiRequest: apiRequest, info: info, @@ -108,8 +111,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "upload_session/append": - return .uploadSessionAppend( + case "files/upload_session/append": + return .files_uploadSessionAppend( rebuildRequest( apiRequest: apiRequest, info: info, @@ -117,8 +120,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "upload_session/finish": - return .uploadSessionFinish( + case "files/upload_session/finish": + return .files_uploadSessionFinish( rebuildRequest( apiRequest: apiRequest, info: info, @@ -126,8 +129,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "upload_session/start": - return .uploadSessionStart( + case "files/upload_session/start": + return .files_uploadSessionStart( rebuildRequest( apiRequest: apiRequest, info: info, @@ -135,8 +138,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "docs/create": - return .docsCreate( + case "paper/docs/create": + return .paper_docsCreate( rebuildRequest( apiRequest: apiRequest, info: info, @@ -144,8 +147,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "docs/download": - return .docsDownload( + case "paper/docs/download": + return .paper_docsDownload( rebuildRequest( apiRequest: apiRequest, info: info, @@ -153,8 +156,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "docs/update": - return .docsUpdate( + case "paper/docs/update": + return .paper_docsUpdate( rebuildRequest( apiRequest: apiRequest, info: info, @@ -162,8 +165,8 @@ enum ReconnectionHelpers: ReconnectionHelpersShared { client: client ) ) - case "get_shared_link_file": - return .getSharedLinkFile( + case "sharing/get_shared_link_file": + return .sharing_getSharedLinkFile( rebuildRequest( apiRequest: apiRequest, info: info, diff --git a/Source/SwiftyDropbox/Shared/Handwritten/DropboxTransportClient.swift b/Source/SwiftyDropbox/Shared/Handwritten/DropboxTransportClient.swift index 6b8390b4..fd18614b 100644 --- a/Source/SwiftyDropbox/Shared/Handwritten/DropboxTransportClient.swift +++ b/Source/SwiftyDropbox/Shared/Handwritten/DropboxTransportClient.swift @@ -27,7 +27,8 @@ public class DropboxTransportClientImpl: DropboxTransportClientInternal { return _serializeOnBackgroundThread } } - private static var staticConfigurationLock = NSLock() + + private static var staticConfigurationLock = NSLock() private static var _serializeOnBackgroundThread: Bool = false public var identifier: String? { diff --git a/Source/SwiftyDropbox/Shared/Handwritten/MockApiRequest.swift b/Source/SwiftyDropbox/Shared/Handwritten/MockApiRequest.swift index 6c9436fe..88b192c6 100644 --- a/Source/SwiftyDropbox/Shared/Handwritten/MockApiRequest.swift +++ b/Source/SwiftyDropbox/Shared/Handwritten/MockApiRequest.swift @@ -61,7 +61,7 @@ class MockApiRequest: ApiRequest { func setProgressHandler(_ handler: @escaping (Progress) -> Void) -> Self { self } func setCompletionHandlerProvider(queue: DispatchQueue?, completionHandlerProvider: RequestCompletionHandlerProvider) -> Self { - self.completionHandler = completionHandlerProvider + completionHandler = completionHandlerProvider return self } diff --git a/Source/SwiftyDropbox/Shared/Handwritten/ReconnectionHelpers+Handwritten.swift b/Source/SwiftyDropbox/Shared/Handwritten/ReconnectionHelpers+Handwritten.swift index 2ff6d7e4..a16aa868 100644 --- a/Source/SwiftyDropbox/Shared/Handwritten/ReconnectionHelpers+Handwritten.swift +++ b/Source/SwiftyDropbox/Shared/Handwritten/ReconnectionHelpers+Handwritten.swift @@ -141,15 +141,19 @@ extension ReconnectionHelpers { return try JSONDecoder().decode(Self.self, from: jsonData) } - var routeName: String { + var baseInfo: PersistedRequestInfoBaseInfo { switch self { case .upload(let info): - return info.routeName + return info case .downloadFile(let downloadInfo): - return downloadInfo.routeName + return downloadInfo } } + var namespaceRouteName: String { + "\(baseInfo.routeNamespace)/\(baseInfo.routeName)" + } + var clientProvidedInfo: String? { switch self { case .upload(let info): diff --git a/Source/SwiftyDropbox/Shared/Handwritten/Request+TokenRefresh.swift b/Source/SwiftyDropbox/Shared/Handwritten/Request+TokenRefresh.swift index 6ec8179e..88cb76ec 100644 --- a/Source/SwiftyDropbox/Shared/Handwritten/Request+TokenRefresh.swift +++ b/Source/SwiftyDropbox/Shared/Handwritten/Request+TokenRefresh.swift @@ -437,7 +437,11 @@ extension RequestWithTokenRefresh { } } - private func callDataCompletionHandler(error: ClientError?, mutableState: MutableState, handlerProvider: @escaping ((NetworkDataTaskResult) -> WrappedCompletionHandler)) { + private func callDataCompletionHandler( + error: ClientError?, + mutableState: MutableState, + handlerProvider: @escaping ((NetworkDataTaskResult) -> WrappedCompletionHandler) + ) { // copy for use out of lock let data = mutableState.data let response = mutableState.response @@ -471,7 +475,11 @@ extension RequestWithTokenRefresh { } } - private func callDownloadCompletionHandler(error: ClientError?, mutableState: MutableState, handlerProvider: @escaping ((NetworkDownloadTaskResult) -> WrappedCompletionHandler)) { + private func callDownloadCompletionHandler( + error: ClientError?, + mutableState: MutableState, + handlerProvider: @escaping ((NetworkDownloadTaskResult) -> WrappedCompletionHandler) + ) { // copy for use out of lock let temporaryDownloadURL = mutableState.temporaryDownloadURL let response = mutableState.response diff --git a/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxAppBaseRequestBox.swift b/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxAppBaseRequestBox.swift index 4d0d5d77..96f70a72 100644 --- a/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxAppBaseRequestBox.swift +++ b/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxAppBaseRequestBox.swift @@ -10,7 +10,7 @@ import SwiftyDropbox extension DropboxAppBaseRequestBox { var objc: DBXRequest { switch self { - case .getThumbnailV2(let swift): + case .files_getThumbnailV2(let swift): return DBXFilesGetThumbnailDownloadRequestFileV2(swift: swift) default: fatalError("For Obj-C compatibility, add this route to the Objective-C compatibility module allow-list") diff --git a/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxBaseRequestBox.swift b/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxBaseRequestBox.swift index 2cfe4f10..b0f15e4c 100644 --- a/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxBaseRequestBox.swift +++ b/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxBaseRequestBox.swift @@ -10,41 +10,41 @@ import SwiftyDropbox extension DropboxBaseRequestBox { var objc: DBXRequest { switch self { - case .alphaUpload(let swift): + case .files_alphaUpload(let swift): return DBXFilesAlphaUploadUploadRequest(swift: swift) - case .download(let swift): + case .files_download(let swift): return DBXFilesDownloadDownloadRequestFile(swift: swift) - case .downloadZip(let swift): + case .files_downloadZip(let swift): return DBXFilesDownloadZipDownloadRequestFile(swift: swift) - case .export(let swift): + case .files_export(let swift): return DBXFilesExportDownloadRequestFile(swift: swift) - case .getPreview(let swift): + case .files_getPreview(let swift): return DBXFilesGetPreviewDownloadRequestFile(swift: swift) - case .getThumbnail(let swift): + case .files_getThumbnail(let swift): return DBXFilesGetThumbnailDownloadRequestFile(swift: swift) - case .getThumbnailV2(let swift): + case .files_getThumbnailV2(let swift): return DBXFilesGetThumbnailDownloadRequestFileV2(swift: swift) - case .paperCreate(let swift): + case .files_paperCreate(let swift): return DBXFilesPaperCreateUploadRequest(swift: swift) - case .paperUpdate(let swift): + case .files_paperUpdate(let swift): return DBXFilesPaperUpdateUploadRequest(swift: swift) - case .upload(let swift): + case .files_upload(let swift): return DBXFilesUploadUploadRequest(swift: swift) - case .uploadSessionAppendV2(let swift): + case .files_uploadSessionAppendV2(let swift): return DBXFilesUploadSessionAppendUploadRequestV2(swift: swift) - case .uploadSessionAppend(let swift): + case .files_uploadSessionAppend(let swift): return DBXFilesUploadSessionAppendUploadRequest(swift: swift) - case .uploadSessionFinish(let swift): + case .files_uploadSessionFinish(let swift): return DBXFilesUploadSessionFinishUploadRequest(swift: swift) - case .uploadSessionStart(let swift): + case .files_uploadSessionStart(let swift): return DBXFilesUploadSessionStartUploadRequest(swift: swift) - case .docsCreate(let swift): + case .paper_docsCreate(let swift): return DBXPaperDocsCreateUploadRequest(swift: swift) - case .docsDownload(let swift): + case .paper_docsDownload(let swift): return DBXPaperDocsDownloadDownloadRequestFile(swift: swift) - case .docsUpdate(let swift): + case .paper_docsUpdate(let swift): return DBXPaperDocsUpdateUploadRequest(swift: swift) - case .getSharedLinkFile(let swift): + case .sharing_getSharedLinkFile(let swift): return DBXSharingGetSharedLinkFileDownloadRequestFile(swift: swift) default: fatalError("For Obj-C compatibility, add this route to the Objective-C compatibility module allow-list") diff --git a/Source/SwiftyDropboxUnitTests/ReconnectionHelperRouteNameTests.swift b/Source/SwiftyDropboxUnitTests/ReconnectionHelperRouteNameTests.swift index 7426d7f2..0c9e52c3 100644 --- a/Source/SwiftyDropboxUnitTests/ReconnectionHelperRouteNameTests.swift +++ b/Source/SwiftyDropboxUnitTests/ReconnectionHelperRouteNameTests.swift @@ -8,16 +8,43 @@ import Foundation import XCTest final class TestReconnectionHelperRouteNameMatching: XCTestCase { - func testMatching() throws { - let route = Files.uploadSessionAppendV2 - let persistedInfo = ReconnectionHelpers.PersistedRequestInfo.upload( - .init( - originalSDKVersion: DropboxClientsManager.sdkVersion, - routeName: route.name, - routeNamespace: route.namespace, - clientProvidedInfo: nil + private let destination = URL(string: "/some/file.jpg")! + + func testMatchingFilesUploadSessionAppendV2() throws { + try executeMatchingTest(route: Files.uploadSessionAppendV2, expectedRebuiltDescription: "files/upload_session/append_v2", upload: true) + } + + func testMatchingFilesDownloadZip() throws { + try executeMatchingTest(route: Files.downloadZip, expectedRebuiltDescription: "files/download_zip", upload: false) + } + + func testMatchingSharingGetSharedLinkFile() throws { + try executeMatchingTest(route: Sharing.getSharedLinkFile, expectedRebuiltDescription: "sharing/get_shared_link_file", upload: false) + } + + func testMatchingPaperDocsDownload() throws { + try executeMatchingTest(route: Paper.docsDownload, expectedRebuiltDescription: "paper/docs/download", upload: false) + } + + private func executeMatchingTest(route: Route, expectedRebuiltDescription: String, upload: Bool) throws { + let persistedInfo: ReconnectionHelpers.PersistedRequestInfo = upload + ? .upload( + .init( + originalSDKVersion: DropboxClientsManager.sdkVersion, + routeName: route.name, + routeNamespace: route.namespace, + clientProvidedInfo: nil + ) + ) + : .downloadFile( + .init( + originalSDKVersion: DropboxClientsManager.sdkVersion, + routeName: route.name, + routeNamespace: route.namespace, + destination: destination, + overwrite: true + ) ) - ) let request = MockApiRequest(identifier: 0) request.taskDescription = try persistedInfo.asJsonString() @@ -25,6 +52,6 @@ final class TestReconnectionHelperRouteNameMatching: XCTestCase { let rebuiltRequest = try ReconnectionHelpers.rebuildRequest(apiRequest: request, client: MockDropboxTransportClient()) // Assert that request was successfully rebuilt - XCTAssertEqual(rebuiltRequest.description, "uploadSessionAppendV2") + XCTAssertEqual(rebuiltRequest.description, expectedRebuiltDescription) } } diff --git a/Source/SwiftyDropboxUnitTests/TestMockingUtilities.swift b/Source/SwiftyDropboxUnitTests/TestMockingUtilities.swift index 7ff8e08d..24c64eba 100644 --- a/Source/SwiftyDropboxUnitTests/TestMockingUtilities.swift +++ b/Source/SwiftyDropboxUnitTests/TestMockingUtilities.swift @@ -88,7 +88,7 @@ final class TestMockingUtilities: XCTestCase { let expectedErrorJSON: [String: Any] = [ "path": [".tag": "not_found"], - ".tag":"path" + ".tag": "path", ] webService.getMetadata { _, error in diff --git a/stone b/stone index a51d760c..87ec270e 160000 --- a/stone +++ b/stone @@ -1 +1 @@ -Subproject commit a51d760cdf271025ae90074275edfa156ca5aaf0 +Subproject commit 87ec270e83620b611751502db30b35b6fafd9de9 From d0058ec84278fc32dde45094acbe2ca801aefad1 Mon Sep 17 00:00:00 2001 From: Julian Locke Date: Mon, 26 Aug 2024 15:08:15 -0400 Subject: [PATCH 2/5] Fix unreachable code warnings when all reconnectable swift routes have compatibiltiy wrappers --- .../DBXDropboxAppBaseRequestBox.swift | 5 +- .../Generated/DBXDropboxBaseRequestBox.swift | 56 ++++++++++++------- stone | 2 +- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxAppBaseRequestBox.swift b/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxAppBaseRequestBox.swift index 96f70a72..a9217e99 100644 --- a/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxAppBaseRequestBox.swift +++ b/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxAppBaseRequestBox.swift @@ -9,10 +9,9 @@ import SwiftyDropbox extension DropboxAppBaseRequestBox { var objc: DBXRequest { - switch self { - case .files_getThumbnailV2(let swift): + if case .files_getThumbnailV2(let swift) = self { return DBXFilesGetThumbnailDownloadRequestFileV2(swift: swift) - default: + } else { fatalError("For Obj-C compatibility, add this route to the Objective-C compatibility module allow-list") } } diff --git a/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxBaseRequestBox.swift b/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxBaseRequestBox.swift index b0f15e4c..870fb546 100644 --- a/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxBaseRequestBox.swift +++ b/Source/SwiftyDropboxObjC/Shared/Generated/DBXDropboxBaseRequestBox.swift @@ -9,44 +9,60 @@ import SwiftyDropbox extension DropboxBaseRequestBox { var objc: DBXRequest { - switch self { - case .files_alphaUpload(let swift): + if case .files_alphaUpload(let swift) = self { return DBXFilesAlphaUploadUploadRequest(swift: swift) - case .files_download(let swift): + } + if case .files_download(let swift) = self { return DBXFilesDownloadDownloadRequestFile(swift: swift) - case .files_downloadZip(let swift): + } + if case .files_downloadZip(let swift) = self { return DBXFilesDownloadZipDownloadRequestFile(swift: swift) - case .files_export(let swift): + } + if case .files_export(let swift) = self { return DBXFilesExportDownloadRequestFile(swift: swift) - case .files_getPreview(let swift): + } + if case .files_getPreview(let swift) = self { return DBXFilesGetPreviewDownloadRequestFile(swift: swift) - case .files_getThumbnail(let swift): + } + if case .files_getThumbnail(let swift) = self { return DBXFilesGetThumbnailDownloadRequestFile(swift: swift) - case .files_getThumbnailV2(let swift): + } + if case .files_getThumbnailV2(let swift) = self { return DBXFilesGetThumbnailDownloadRequestFileV2(swift: swift) - case .files_paperCreate(let swift): + } + if case .files_paperCreate(let swift) = self { return DBXFilesPaperCreateUploadRequest(swift: swift) - case .files_paperUpdate(let swift): + } + if case .files_paperUpdate(let swift) = self { return DBXFilesPaperUpdateUploadRequest(swift: swift) - case .files_upload(let swift): + } + if case .files_upload(let swift) = self { return DBXFilesUploadUploadRequest(swift: swift) - case .files_uploadSessionAppendV2(let swift): + } + if case .files_uploadSessionAppendV2(let swift) = self { return DBXFilesUploadSessionAppendUploadRequestV2(swift: swift) - case .files_uploadSessionAppend(let swift): + } + if case .files_uploadSessionAppend(let swift) = self { return DBXFilesUploadSessionAppendUploadRequest(swift: swift) - case .files_uploadSessionFinish(let swift): + } + if case .files_uploadSessionFinish(let swift) = self { return DBXFilesUploadSessionFinishUploadRequest(swift: swift) - case .files_uploadSessionStart(let swift): + } + if case .files_uploadSessionStart(let swift) = self { return DBXFilesUploadSessionStartUploadRequest(swift: swift) - case .paper_docsCreate(let swift): + } + if case .paper_docsCreate(let swift) = self { return DBXPaperDocsCreateUploadRequest(swift: swift) - case .paper_docsDownload(let swift): + } + if case .paper_docsDownload(let swift) = self { return DBXPaperDocsDownloadDownloadRequestFile(swift: swift) - case .paper_docsUpdate(let swift): + } + if case .paper_docsUpdate(let swift) = self { return DBXPaperDocsUpdateUploadRequest(swift: swift) - case .sharing_getSharedLinkFile(let swift): + } + if case .sharing_getSharedLinkFile(let swift) = self { return DBXSharingGetSharedLinkFileDownloadRequestFile(swift: swift) - default: + } else { fatalError("For Obj-C compatibility, add this route to the Objective-C compatibility module allow-list") } } diff --git a/stone b/stone index 87ec270e..018e3d61 160000 --- a/stone +++ b/stone @@ -1 +1 @@ -Subproject commit 87ec270e83620b611751502db30b35b6fafd9de9 +Subproject commit 018e3d61e6f4236890ed34768abe2975bc0283c0 From 5bd2295fe682d91dfddb5d08ffd6a81403bde6bc Mon Sep 17 00:00:00 2001 From: Julian Locke Date: Mon, 26 Aug 2024 16:07:18 -0400 Subject: [PATCH 3/5] Fix hash and client var name collision errors --- stone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stone b/stone index 018e3d61..97f07dc4 160000 --- a/stone +++ b/stone @@ -1 +1 @@ -Subproject commit 018e3d61e6f4236890ed34768abe2975bc0283c0 +Subproject commit 97f07dc469d47c4c2fc17b86a5f338261d45800c From 9f6beb31663031c0104dd0c3cfd4eb48f675d361 Mon Sep 17 00:00:00 2001 From: Julian Locke Date: Tue, 27 Aug 2024 11:46:47 -0400 Subject: [PATCH 4/5] fix tests --- .../DebugBackgroundSessionViewModel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestSwiftyDropbox/TestSwiftyDropbox_iOS/DebugBackgroundSessionViewModel.swift b/TestSwiftyDropbox/TestSwiftyDropbox_iOS/DebugBackgroundSessionViewModel.swift index fca79af7..e0c04a81 100644 --- a/TestSwiftyDropbox/TestSwiftyDropbox_iOS/DebugBackgroundSessionViewModel.swift +++ b/TestSwiftyDropbox/TestSwiftyDropbox_iOS/DebugBackgroundSessionViewModel.swift @@ -108,7 +108,7 @@ class DebugBackgroundSessionViewModel: ObservableObject { for request in successfulReturnedRequests { switch request { - case .download(let downloadRequest): + case .files_download(let downloadRequest): downloadRequest.response { response, error in if let result = response { let writtenContent = String(data: FileManager.default.contents(atPath: result.1.path()) ?? .init(), encoding: .utf8) @@ -117,7 +117,7 @@ class DebugBackgroundSessionViewModel: ObservableObject { DropboxClientsManager.logBackgroundSession("attemptReconnect download errored: \(callError)") } } - case .upload(let uploadRequest): + case .files_upload(let uploadRequest): uploadRequest.response { response, error in if let result = response { DropboxClientsManager.logBackgroundSession("attemptReconnect upload complete with size: \(result.size)") From 20c9001f44a395f3be81d8d39ca38af602d08e5e Mon Sep 17 00:00:00 2001 From: Julian Locke Date: Tue, 27 Aug 2024 13:38:57 -0400 Subject: [PATCH 5/5] Point to latest stone --- stone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stone b/stone index 97f07dc4..2f1763c2 160000 --- a/stone +++ b/stone @@ -1 +1 @@ -Subproject commit 97f07dc469d47c4c2fc17b86a5f338261d45800c +Subproject commit 2f1763c292410aefa3bbdd208f364c5d324eb4e5