Cross-platform Xcode replacement. Build and deploy iOS apps with SwiftPM on Linux, Windows, macOS.
More OpenAPI
Kabir Oberai1f61b71e21da
diff --git a/Sources/Supersign/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift b/Sources/Supersign/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swiftindex 627de61..a7ef9a9 100644--- a/Sources/Supersign/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift+++ b/Sources/Supersign/DeveloperServices/App IDs/DeveloperServicesAddAppOperation.swift@@ -139,9 +139,7 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {try entitlements.setEntitlements(entitlementsArray)}- let profile = try await DeveloperServicesFetchProfileOperation(context: self.context, appID: appID).perform()- guard let mobileprovision = profile.mobileprovision- else { throw Mobileprovision.Error.invalidProfile }+ let mobileprovision = try await DeveloperServicesFetchProfileOperation(context: self.context, bundleID: appID.bundleID).perform()return ProvisioningInfo(newBundleID: appID.bundleID, entitlements: entitlements, mobileprovision: mobileprovision)diff --git a/Sources/Supersign/DeveloperServices/App IDs/DeveloperServicesDeleteAppIDRequest.swift b/Sources/Supersign/DeveloperServices/App IDs/DeveloperServicesDeleteAppIDRequest.swiftdeleted file mode 100644index 2808da4..0000000--- a/Sources/Supersign/DeveloperServices/App IDs/DeveloperServicesDeleteAppIDRequest.swift+++ /dev/null@@ -1,35 +0,0 @@-//-// DeveloperServicesDeleteAppIDRequest.swift-// Supercharge-//-// Created by Kabir Oberai on 24/07/19.-// Copyright © 2019 Kabir Oberai. All rights reserved.-//--import Foundation--public struct DeveloperServicesDeleteAppIDRequest: DeveloperServicesPlatformRequest {-- public struct Response: Decodable, Sendable {}- public typealias Value = Response-- public let platform: DeveloperServicesPlatform- public let teamID: DeveloperServicesTeam.ID- public let appIDID: DeveloperServicesAppID.ID-- var subAction: String { return "deleteAppId" }- var subParameters: [String: Any] {- return ["teamId": teamID.rawValue, "appIdId": appIDID.rawValue]- }-- public init(- platform: DeveloperServicesPlatform,- teamID: DeveloperServicesTeam.ID,- appIDID: DeveloperServicesAppID.ID- ) {- self.platform = platform- self.teamID = teamID- self.appIDID = appIDID- }--}diff --git a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesDeleteProfileRequest.swift b/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesDeleteProfileRequest.swiftdeleted file mode 100644index 20513f8..0000000--- a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesDeleteProfileRequest.swift+++ /dev/null@@ -1,35 +0,0 @@-//-// DeveloperServicesDeleteProfileRequest.swift-// Supercharge-//-// Created by Kabir Oberai on 24/07/19.-// Copyright © 2019 Kabir Oberai. All rights reserved.-//--import Foundation--public struct DeveloperServicesDeleteProfileRequest: DeveloperServicesPlatformRequest {-- public struct Response: Decodable, Sendable {}- public typealias Value = Response-- public let platform: DeveloperServicesPlatform- public let teamID: DeveloperServicesTeam.ID- public let profileID: DeveloperServicesProfile.ID-- var subAction: String { return "deleteProvisioningProfile" }- var subParameters: [String: Any] {- return ["teamId": teamID.rawValue, "provisioningProfileId": profileID.rawValue]- }-- public init(- platform: DeveloperServicesPlatform,- teamID: DeveloperServicesTeam.ID,- profileID: DeveloperServicesProfile.ID- ) {- self.platform = platform- self.teamID = teamID- self.profileID = profileID- }--}diff --git a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swift b/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swiftindex 99de067..d4fdc7f 100644--- a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swift+++ b/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesFetchProfileOperation.swift@@ -8,28 +8,91 @@import Foundationimport Superutils+import DeveloperAPIpublic struct DeveloperServicesFetchProfileOperation: DeveloperServicesOperation {+ public enum Errors: Error {+ case bundleIDNotFound+ case tooManyMatchingBundleIDs+ case invalidProfileData+ }+public let context: SigningContext- public let appID: DeveloperServicesAppID- public init(context: SigningContext, appID: DeveloperServicesAppID) {+ public let bundleID: String+ public init(context: SigningContext, bundleID: String) {self.context = context- self.appID = appID+ self.bundleID = bundleID}- public func perform() async throws -> DeveloperServicesProfile {- let profiles = try await context.client.send(DeveloperServicesListProfilesRequest(- platform: context.platform, teamID: context.teamID- ))- if let profile = profiles.first(where: { $0.appID.id == self.appID.id }) {- _ = try await context.client.send(DeveloperServicesDeleteProfileRequest(- platform: context.platform, teamID: context.teamID, profileID: profile.id+ public func perform() async throws -> Mobileprovision {+ let bundleIDs = try await context.developerAPIClient+ .bundleIdsGetCollection(query: .init(+ filter_lbrack_identifier_rbrack_: [bundleID],+ include: [.profiles]))+ .ok.body.json++ let bundleID: Components.Schemas.BundleId+ switch bundleIDs.data.count {+ case 0:+ throw Errors.bundleIDNotFound+ case 1:+ bundleID = bundleIDs.data[0]+ default:+ throw Errors.tooManyMatchingBundleIDs}- return try await context.client.send(DeveloperServicesGetProfileRequest(- platform: context.platform, teamID: context.teamID, appIDID: appID.id- ))++ let profiles = bundleIDs+ .included?+ .compactMap { included -> Components.Schemas.Profile? in+ if case .Profile(let profile) = included {+ profile+ } else {+ nil+ }+ } ?? []++ switch profiles.count {+ case 0:+ // we're good+ break+ case 1:+ _ = try await context.developerAPIClient.profilesDeleteInstance(path: .init(id: profiles[0].id)).noContent+ default:+ // if the user has >1 profile, it's probably okay to add another one (acceptable for non-free accounts?)+ break+ }++ let response = try await context.developerAPIClient.profilesCreateInstance(+ body: .json(+ .init(+ data: .init(+ _type: .profiles,+ attributes: .init(+ name: "SC profile \(bundleID)",+ profileType: .iosAppDevelopment+ ),+ relationships: .init(+ bundleId: .init(+ data: .init(+ _type: .bundleIds,+ id: bundleID.id+ )+ ),+ certificates: .init(data: [])+ )+ )+ )+ )+ )+ .created.body.json.data++ guard let contentString = response.attributes?.profileContent,+ let contentData = Data(base64Encoded: contentString)+ else { throw Errors.invalidProfileData }++ return try Mobileprovision(data: contentData)}}diff --git a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesGetProfileRequest.swift b/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesGetProfileRequest.swiftdeleted file mode 100644index e78863e..0000000--- a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesGetProfileRequest.swift+++ /dev/null@@ -1,41 +0,0 @@-//-// DeveloperServicesGetProfileRequest.swift-// Supercharge-//-// Created by Kabir Oberai on 24/07/19.-// Copyright © 2019 Kabir Oberai. All rights reserved.-//--import Foundation--public struct DeveloperServicesGetProfileRequest: DeveloperServicesPlatformRequest {-- public struct Response: Decodable, Sendable {- public let provisioningProfile: DeveloperServicesProfile- }- public typealias Value = DeveloperServicesProfile-- public let platform: DeveloperServicesPlatform- public let teamID: DeveloperServicesTeam.ID- public let appIDID: DeveloperServicesAppID.ID-- var subAction: String { return "downloadTeamProvisioningProfile" }- var subParameters: [String: Any] {- return ["teamId": teamID.rawValue, "appIdId": appIDID.rawValue]- }-- public func parse(_ response: Response) -> DeveloperServicesProfile {- response.provisioningProfile- }-- public init(- platform: DeveloperServicesPlatform,- teamID: DeveloperServicesTeam.ID,- appIDID: DeveloperServicesAppID.ID- ) {- self.platform = platform- self.teamID = teamID- self.appIDID = appIDID- }--}diff --git a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesListProfilesRequest.swift b/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesListProfilesRequest.swiftdeleted file mode 100644index c6f1439..0000000--- a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesListProfilesRequest.swift+++ /dev/null@@ -1,35 +0,0 @@-//-// DeveloperServicesListProfilesRequest.swift-// Supercharge-//-// Created by Kabir Oberai on 24/07/19.-// Copyright © 2019 Kabir Oberai. All rights reserved.-//--import Foundation--public struct DeveloperServicesListProfilesRequest: DeveloperServicesPlatformRequest {-- public struct Response: Decodable, Sendable {- public let provisioningProfiles: [DeveloperServicesProfile]- }- public typealias Value = [DeveloperServicesProfile]-- public let platform: DeveloperServicesPlatform- public let teamID: DeveloperServicesTeam.ID-- var subAction: String { return "listProvisioningProfiles" }- var subParameters: [String: Any] {- return ["teamId": teamID.rawValue]- }-- public func parse(_ response: Response) -> [DeveloperServicesProfile] {- response.provisioningProfiles- }-- public init(platform: DeveloperServicesPlatform, teamID: DeveloperServicesTeam.ID) {- self.platform = platform- self.teamID = teamID- }--}diff --git a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesProfile.swift b/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesProfile.swiftdeleted file mode 100644index 937c095..0000000--- a/Sources/Supersign/DeveloperServices/Profiles/DeveloperServicesProfile.swift+++ /dev/null@@ -1,44 +0,0 @@-//-// DeveloperServicesProfile.swift-// Supercharge-//-// Created by Kabir Oberai on 29/07/19.-// Copyright © 2019 Kabir Oberai. All rights reserved.-//--import Foundation--public struct DeveloperServicesProfile: Decodable, Sendable {- public struct ID: RawRepresentable, Decodable, Sendable {- public let rawValue: String- public init(rawValue: String) { self.rawValue = rawValue }- }-- public let id: ID- public let name: String- public let status: String- public let type: String- public let platform: DeveloperServicesPlatform- public let uuid: String- public let version: String- public let expiry: Date- public let appIDID: DeveloperServicesAppID.ID- public let appID: DeveloperServicesAppID- public let isFree: Bool- public let mobileprovision: Mobileprovision?-- private enum CodingKeys: String, CodingKey {- case id = "provisioningProfileId"- case name- case status- case type- case platform = "proProPlatform"- case uuid = "UUID"- case version- case expiry = "dateExpire"- case appIDID = "appIdId"- case appID = "appId"- case isFree = "isFreeProvisioningProfile"- case mobileprovision = "encodedProfile"- }-}diff --git a/Sources/Supersign/DeveloperServices/Developer/DeveloperServicesViewDeveloperRequest.swift b/Sources/Supersign/DeveloperServices/Teams/DeveloperServicesViewDeveloperRequest.swiftsimilarity index 100%rename from Sources/Supersign/DeveloperServices/Developer/DeveloperServicesViewDeveloperRequest.swiftrename to Sources/Supersign/DeveloperServices/Teams/DeveloperServicesViewDeveloperRequest.swift