Repository navigation
Add first-class async/await networking API - #2
Merged
Merged
Conversation
Modernizes the library around Swift concurrency while keeping the existing completion handler API intact: - New AsyncRequestManager (backed by the AsyncRequestable protocol) offering a vanilla async request, CRUD conveniences (create/read/update/delete), download and upload APIs, plus a Decodable-returning request built on top of a configurable decoder - Downloaded files are relocated out of URLSession's ephemeral storage so they remain usable after the call returns - New PATCH case in HTTPMethod, surfaced through update(_:payload:method:) - Extracted shared HTTP response validation into ResponseValidator so every API flavor maps NetworkError consistently - Fixed URLSession.dataTaskWithURL dropping the request's HTTP method, headers and body by forwarding only its URL - URLSessionable now covers data, download and upload tasks; its completion typealiases are @sendable to match URLSession's contract - Bumped tools version to 5.7, declared tvOS/watchOS floors and made the package build on Linux (FoundationNetworking imports, Combine agent conditionally compiled, stale LinuxMain/XCTestManifests removed in favor of automatic test discovery) - Unit tests for every async use case (success, transport failure, HTTP error mapping, CRUD verb stamping, decoding, upload recording, download persistence) - README overhauled with SPM installation steps and async/await usage examples Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017esYpGrJ3HtXUTaGiJ5jff
Per the n-2 support policy (keep up to two versions behind current): - swift-tools 6.0 with Swift 6 language mode; floors raised to iOS 17 / macOS 14 / tvOS 17 / watchOS 10 - URLSessionable reshaped into async requirements (retrieveData, downloadFile, upload) forwarding to URLSession's native async APIs, replacing the hand-rolled continuation wrappers. Task cancellation now propagates to the underlying network request - Transport failures map through ResponseValidator.mapTransportFailure: URLError/CancellationError cancellations -> .cancelled, timeouts -> .timeout, anything else -> .unknown - Audited Sendable conformances across the public surface - Legacy RequestManager bridges its completion API through AsyncRequestManager instead of duplicating the session plumbing - Test doubles no longer subclass deprecated URLSessionTask types; new transport-failure mapping tests added (31 tests total) - README requirements and testability example updated Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017esYpGrJ3HtXUTaGiJ5jff
mchirino89
commented
Jul 4, 2026
- Remove the completion-handler API (RequestManager, RequestableManager, NetworkResult) and its tests: the library is now async-only - Remove APIEndpoint, EndpointBuilder, URLBuilderResult/URLBuilderError, APIScheme and their tests, plus the now-orphaned URLComponents/ Collection helpers and unused HTTPEncoding - Remove the internal WIP Combine Agent (drops the last Combine import) - Rename RequestableManager.swift to URLSessionable.swift to match its remaining content - download now accepts an explicit destination directory (download(_:into:)), defaulting to the temporary directory via a protocol extension, so the relocation target is injectable and assertable in tests - Replace force unwraps with XCTUnwrap in test payload setup - Purge downloaded artifacts via addTeardownBlock so cleanup runs regardless of test outcome - Document the uploaded payload variable in the upload example (doc comment and README); drop the legacy and endpoint-assembling README sections Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017esYpGrJ3HtXUTaGiJ5jff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Rebuilds MauriNet as an async-only networking library on Swift 6, replacing both the completion-handler API and the WIP Combine agent with first-class Swift concurrency.
New async/await API
AsyncRequestManager(backed by the new publicAsyncRequestableprotocol):request(_:) async throws -> Datarequest(_:decoder:) async throws -> Modelfor anyDecodablecreate(POST),read(GET),update(PUT or PATCH),delete(DELETE) — they stamp the HTTP verb and attach the payload for youdownload(_:into:)— relocates the file out ofURLSession's ephemeral storage into an explicit (injectable, testable) destination directory;download(_:)convenience defaults to the temporary directoryupload(_:from:)URLSession's native async APIs (data(for:)/download(for:)/upload(for:from:)), so cancelling the surroundingTaskcancels the network request (surfaced asNetworkError.cancelled)NetworkError: HTTP status codes map via the sharedResponseValidator, transport failures map throughmapTransportFailure(cancellation →.cancelled, timeout →.timeout, anything else →.unknown)HTTPMethod.patchcaseURLSessionableis a lean async protocol (retrieveData/downloadFile/upload) thatURLSessionconforms to — mocks are plain types, no more subclassing deprecatedURLSessionTasktypesLegacy purge (per review)
RequestManager,RequestableManager,NetworkResultAPIEndpoint,EndpointBuilder,URLBuilderResult/URLBuilderError,APIScheme, plus orphanedURLComponents/Collectionhelpers and unusedHTTPEncodingAgentremoved (drops the last Combine import)Platform floor (n−2 policy)
Sendableconformances across the public surface0.2.1tagPackage modernization
FoundationNetworkingimports)LinuxMain.swift/XCTestManifests.swift(referencing a nonexistent class) removed in favor of automatic test discoveryTests
24 tests, all passing, zero build warnings (verified with Swift 6.0.3 in Swift 6 language mode): success paths, non-HTTP responses, HTTP error mapping, transport-failure mapping, CRUD verb stamping and payload attachment,
Decodablesuccess/failure, upload payload recording, download persistence and destination-directory injection. Payload setup usesXCTUnwrap(no force unwraps) and downloaded artifacts are purged viaaddTeardownBlockregardless of test outcome.Documentation
Decodablerequests, downloads (including explicit destination), uploads and testabilitydocs/intentionally untouched)🤖 Generated with Claude Code
https://claude.ai/code/session_017esYpGrJ3HtXUTaGiJ5jff