diff --git a/Package.swift b/Package.swift index f204ba4..7c17bf9 100644 --- a/Package.swift +++ b/Package.swift @@ -14,7 +14,7 @@ let package = Package( // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "SwiftNet", - targets: ["SwiftNet", "SwiftNetMacros"]) + targets: ["SwiftNet", "SNUtilities", "SwiftNetMacros"]) ], dependencies: [ // Dependencies declare other packages that this package depends on. @@ -29,18 +29,20 @@ let package = Package( dependencies: [ .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), - "SwiftNet" + "SNUtilities" ] ), .target( name: "SwiftNet", - exclude: ["../../SwiftNet.podspec"]), + dependencies: ["SNUtilities", "SwiftNetMacros"], + exclude: ["../../SwiftNet-macroless.podspec"]), + .target(name: "SNUtilities"), + .target( + name: "SwiftNetMacros", + dependencies: ["SNMacros", "SNUtilities"]), .testTarget( name: "SwiftNetTests", dependencies: ["SwiftNet", "SwiftNetMacros", "SNMacros"]), - .target( - name: "SwiftNetMacros", - dependencies: ["SNMacros", "SwiftNet"]), .testTarget( name: "SwiftNetMacrosTests", dependencies: [ diff --git a/Sources/SwiftNet/Data/AccessTokenConvertible.swift b/Sources/SNUtilities/Authorization/AccessTokenConvertible.swift similarity index 100% rename from Sources/SwiftNet/Data/AccessTokenConvertible.swift rename to Sources/SNUtilities/Authorization/AccessTokenConvertible.swift diff --git a/Sources/SwiftNet/Config/AccessTokenStrategy.swift b/Sources/SNUtilities/Authorization/AccessTokenStrategy.swift similarity index 94% rename from Sources/SwiftNet/Config/AccessTokenStrategy.swift rename to Sources/SNUtilities/Authorization/AccessTokenStrategy.swift index 3586799..972f1e9 100644 --- a/Sources/SwiftNet/Config/AccessTokenStrategy.swift +++ b/Sources/SNUtilities/Authorization/AccessTokenStrategy.swift @@ -8,7 +8,7 @@ public enum AccessTokenStrategy { case global, custom(String) - var storingLabel: String { + public var storingLabel: String { switch self { case .global: return "accessToken_SwiftNet" diff --git a/Sources/SwiftNet/Request/SNAccessToken.swift b/Sources/SNUtilities/Authorization/SNAccessToken.swift similarity index 100% rename from Sources/SwiftNet/Request/SNAccessToken.swift rename to Sources/SNUtilities/Authorization/SNAccessToken.swift diff --git a/Sources/SwiftNet/Data/Boundary.swift b/Sources/SNUtilities/Request/Boundary.swift similarity index 100% rename from Sources/SwiftNet/Data/Boundary.swift rename to Sources/SNUtilities/Request/Boundary.swift diff --git a/Sources/SwiftNet/Data/EndpointData.swift b/Sources/SNUtilities/Request/EndpointData.swift similarity index 100% rename from Sources/SwiftNet/Data/EndpointData.swift rename to Sources/SNUtilities/Request/EndpointData.swift diff --git a/Sources/SwiftNet/EndpointBuilder/EndpointDescriptor.swift b/Sources/SNUtilities/Request/EndpointDescriptor.swift similarity index 100% rename from Sources/SwiftNet/EndpointBuilder/EndpointDescriptor.swift rename to Sources/SNUtilities/Request/EndpointDescriptor.swift diff --git a/Sources/SwiftNet/Request/Method.swift b/Sources/SNUtilities/Request/Method.swift similarity index 100% rename from Sources/SwiftNet/Request/Method.swift rename to Sources/SNUtilities/Request/Method.swift diff --git a/Sources/SwiftNet/Config/SNConfig + extensions.swift b/Sources/SwiftNet/Config/SNConfig + extensions.swift index 10b3808..db4bc53 100644 --- a/Sources/SwiftNet/Config/SNConfig + extensions.swift +++ b/Sources/SwiftNet/Config/SNConfig + extensions.swift @@ -7,6 +7,7 @@ import Foundation + extension SNConfig { //MARK: set access token methods diff --git a/Sources/SwiftNet/Data/AccessTokenStorage.swift b/Sources/SwiftNet/Data/AccessTokenStorage.swift index c3ed02e..e2a871e 100644 --- a/Sources/SwiftNet/Data/AccessTokenStorage.swift +++ b/Sources/SwiftNet/Data/AccessTokenStorage.swift @@ -7,6 +7,7 @@ import Foundation + extension SNConfig { fileprivate static var accessTokens: [String: SNAccessToken] = [:] } diff --git a/Sources/SwiftNet/EndpointBuilder/EndpointBuilder.swift b/Sources/SwiftNet/EndpointBuilder/EndpointBuilder.swift index 87b6276..3692b65 100644 --- a/Sources/SwiftNet/EndpointBuilder/EndpointBuilder.swift +++ b/Sources/SwiftNet/EndpointBuilder/EndpointBuilder.swift @@ -8,6 +8,7 @@ import Foundation import Combine + public protocol EndpointBuilderAbstract { associatedtype T: Codable & Equatable diff --git a/Sources/SwiftNet/EndpointBuilder/EndpointModel.swift b/Sources/SwiftNet/EndpointBuilder/EndpointModel.swift index a04d84a..0fdebd3 100644 --- a/Sources/SwiftNet/EndpointBuilder/EndpointModel.swift +++ b/Sources/SwiftNet/EndpointBuilder/EndpointModel.swift @@ -8,6 +8,7 @@ import Foundation import Combine + public protocol EndpointModel { var identifier: String { get } static var defaultAccessTokenStrategy: AccessTokenStrategy { get } diff --git a/Sources/SwiftNet/Request/AnyPublisher + asAccessTokenConvertible.swift b/Sources/SwiftNet/Request/AnyPublisher + asAccessTokenConvertible.swift index ba072f7..07e9a78 100644 --- a/Sources/SwiftNet/Request/AnyPublisher + asAccessTokenConvertible.swift +++ b/Sources/SwiftNet/Request/AnyPublisher + asAccessTokenConvertible.swift @@ -8,6 +8,7 @@ import Foundation import Combine + extension AnyPublisher { /// Converts publisher to return object responding to AccessTokenConvertible in case of success public func asAccessTokenConvertible() throws -> AnyPublisher { diff --git a/Sources/SwiftNet/Request/SNProvider.swift b/Sources/SwiftNet/Request/SNProvider.swift index cd2f82a..d909996 100644 --- a/Sources/SwiftNet/Request/SNProvider.swift +++ b/Sources/SwiftNet/Request/SNProvider.swift @@ -7,6 +7,8 @@ import Foundation @_exported import Combine +@_exported import SNUtilities +@_exported import SwiftNetMacros fileprivate func runOnMain(_ completion: @escaping () -> Void) { DispatchQueue.main.async { diff --git a/Sources/SwiftNetMacros/SwiftNetMacros.swift b/Sources/SwiftNetMacros/SwiftNetMacros.swift index b02bbb9..bbc6725 100644 --- a/Sources/SwiftNetMacros/SwiftNetMacros.swift +++ b/Sources/SwiftNetMacros/SwiftNetMacros.swift @@ -1,7 +1,7 @@ // The Swift Programming Language // https://docs.swift.org/swift-book -import SwiftNet +import SNUtilities @attached(member, names: named(url), named(identifier), named(staticIdentifier)) public macro Endpoint(url: String) = #externalMacro(module: "SNMacros", type: "EndpointMacro")