Compare commits

..

2 Commits

12 changed files with 104 additions and 352 deletions
+2 -2
View File
@@ -144,8 +144,8 @@ api: openapi/openapi.json
update-api:
@+$(MAKE) -B api
openapi/openapi.json: openapi/base.json Sources/DeveloperAPI/patch.js
node Sources/DeveloperAPI/patch.js < openapi/base.json > openapi/openapi.json
openapi/openapi.json: openapi/base.json Sources/DeveloperAPI/openapi-overlay.yaml
npx --yes bump-cli overlay openapi/base.json Sources/DeveloperAPI/openapi-overlay.yaml > openapi/openapi.json
openapi/base.json:
@mkdir -p openapi
+1 -1
View File
@@ -88,7 +88,7 @@ let package = Package(
dependencies: [
.product(name: "OpenAPIRuntime", package: "swift-openapi-runtime"),
],
exclude: ["openapi-generator-config.yaml", "patch.js"]
exclude: ["openapi-generator-config.yaml", "openapi-overlay.yaml"]
),
.target(
name: "XKit",
+63 -247
View File
@@ -1299,6 +1299,7 @@ public enum Components {
/// - Remark: Generated from `#/components/schemas/App/relationships/appAvailabilityV2`.
public var appAvailabilityV2: Components.Schemas.App.RelationshipsPayload.AppAvailabilityV2Payload?
/// - Remark: Generated from `#/components/schemas/App/relationships/inAppPurchases`.
@available(*, deprecated)
public struct InAppPurchasesPayload: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/App/relationships/inAppPurchases/links`.
public var links: Components.Schemas.RelationshipLinks?
@@ -1357,6 +1358,7 @@ public enum Components {
}
}
/// - Remark: Generated from `#/components/schemas/App/relationships/inAppPurchases`.
@available(*, deprecated)
public var inAppPurchases: Components.Schemas.App.RelationshipsPayload.InAppPurchasesPayload?
/// - Remark: Generated from `#/components/schemas/App/relationships/subscriptionGroups`.
public struct SubscriptionGroupsPayload: Codable, Hashable, Sendable {
@@ -3464,60 +3466,14 @@ public enum Components {
/// - Remark: Generated from `#/components/schemas/Device/attributes/udid`.
public var udid: Swift.String?
/// - Remark: Generated from `#/components/schemas/Device/attributes/deviceClass`.
public struct DeviceClassPayload: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/Device/attributes/deviceClass/value1`.
@frozen public enum Value1Payload: String, Codable, Hashable, Sendable, CaseIterable {
case appleWatch = "APPLE_WATCH"
case ipad = "IPAD"
case iphone = "IPHONE"
case ipod = "IPOD"
case appleTv = "APPLE_TV"
case mac = "MAC"
}
/// - Remark: Generated from `#/components/schemas/Device/attributes/deviceClass/value1`.
public var value1: Components.Schemas.Device.AttributesPayload.DeviceClassPayload.Value1Payload?
/// - Remark: Generated from `#/components/schemas/Device/attributes/deviceClass/value2`.
public var value2: Swift.String?
/// Creates a new `DeviceClassPayload`.
///
/// - Parameters:
/// - value1:
/// - value2:
public init(
value1: Components.Schemas.Device.AttributesPayload.DeviceClassPayload.Value1Payload? = nil,
value2: Swift.String? = nil
) {
self.value1 = value1
self.value2 = value2
}
public init(from decoder: any Decoder) throws {
var errors: [any Error] = []
do {
self.value1 = try decoder.decodeFromSingleValueContainer()
} catch {
errors.append(error)
}
do {
self.value2 = try decoder.decodeFromSingleValueContainer()
} catch {
errors.append(error)
}
try Swift.DecodingError.verifyAtLeastOneSchemaIsNotNil(
[
self.value1,
self.value2
],
type: Self.self,
codingPath: decoder.codingPath,
errors: errors
)
}
public func encode(to encoder: any Encoder) throws {
try encoder.encodeFirstNonNilValueToSingleValueContainer([
self.value1,
self.value2
])
}
@frozen public enum DeviceClassPayload: String, Codable, Hashable, Sendable, CaseIterable {
case appleWatch = "APPLE_WATCH"
case ipad = "IPAD"
case iphone = "IPHONE"
case ipod = "IPOD"
case appleTv = "APPLE_TV"
case mac = "MAC"
case appleVisionPro = "APPLE_VISION_PRO"
}
/// - Remark: Generated from `#/components/schemas/Device/attributes/deviceClass`.
public var deviceClass: Components.Schemas.Device.AttributesPayload.DeviceClassPayload?
@@ -5061,57 +5017,11 @@ public enum Components {
}
}
/// - Remark: Generated from `#/components/schemas/BundleIdPlatform`.
public struct BundleIdPlatform: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/BundleIdPlatform/value1`.
@frozen public enum Value1Payload: String, Codable, Hashable, Sendable, CaseIterable {
case ios = "IOS"
case macOs = "MAC_OS"
case universal = "UNIVERSAL"
}
/// - Remark: Generated from `#/components/schemas/BundleIdPlatform/value1`.
public var value1: Components.Schemas.BundleIdPlatform.Value1Payload?
/// - Remark: Generated from `#/components/schemas/BundleIdPlatform/value2`.
public var value2: Swift.String?
/// Creates a new `BundleIdPlatform`.
///
/// - Parameters:
/// - value1:
/// - value2:
public init(
value1: Components.Schemas.BundleIdPlatform.Value1Payload? = nil,
value2: Swift.String? = nil
) {
self.value1 = value1
self.value2 = value2
}
public init(from decoder: any Decoder) throws {
var errors: [any Error] = []
do {
self.value1 = try decoder.decodeFromSingleValueContainer()
} catch {
errors.append(error)
}
do {
self.value2 = try decoder.decodeFromSingleValueContainer()
} catch {
errors.append(error)
}
try Swift.DecodingError.verifyAtLeastOneSchemaIsNotNil(
[
self.value1,
self.value2
],
type: Self.self,
codingPath: decoder.codingPath,
errors: errors
)
}
public func encode(to encoder: any Encoder) throws {
try encoder.encodeFirstNonNilValueToSingleValueContainer([
self.value1,
self.value2
])
}
@frozen public enum BundleIdPlatform: String, Codable, Hashable, Sendable, CaseIterable {
case ios = "IOS"
case macOs = "MAC_OS"
case universal = "UNIVERSAL"
case services = "SERVICES"
}
/// - Remark: Generated from `#/components/schemas/CapabilityOption`.
public struct CapabilityOption: Codable, Hashable, Sendable {
@@ -5241,150 +5151,56 @@ public enum Components {
}
}
/// - Remark: Generated from `#/components/schemas/CapabilityType`.
public struct CapabilityType: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/CapabilityType/value1`.
@frozen public enum Value1Payload: String, Codable, Hashable, Sendable, CaseIterable {
case icloud = "ICLOUD"
case inAppPurchase = "IN_APP_PURCHASE"
case gameCenter = "GAME_CENTER"
case pushNotifications = "PUSH_NOTIFICATIONS"
case wallet = "WALLET"
case interAppAudio = "INTER_APP_AUDIO"
case maps = "MAPS"
case associatedDomains = "ASSOCIATED_DOMAINS"
case personalVpn = "PERSONAL_VPN"
case appGroups = "APP_GROUPS"
case healthkit = "HEALTHKIT"
case homekit = "HOMEKIT"
case wirelessAccessoryConfiguration = "WIRELESS_ACCESSORY_CONFIGURATION"
case applePay = "APPLE_PAY"
case dataProtection = "DATA_PROTECTION"
case sirikit = "SIRIKIT"
case networkExtensions = "NETWORK_EXTENSIONS"
case multipath = "MULTIPATH"
case hotSpot = "HOT_SPOT"
case nfcTagReading = "NFC_TAG_READING"
case classkit = "CLASSKIT"
case autofillCredentialProvider = "AUTOFILL_CREDENTIAL_PROVIDER"
case accessWifiInformation = "ACCESS_WIFI_INFORMATION"
case networkCustomProtocol = "NETWORK_CUSTOM_PROTOCOL"
case coremediaHlsLowLatency = "COREMEDIA_HLS_LOW_LATENCY"
case systemExtensionInstall = "SYSTEM_EXTENSION_INSTALL"
case userManagement = "USER_MANAGEMENT"
case appleIdAuth = "APPLE_ID_AUTH"
}
/// - Remark: Generated from `#/components/schemas/CapabilityType/value1`.
public var value1: Components.Schemas.CapabilityType.Value1Payload?
/// - Remark: Generated from `#/components/schemas/CapabilityType/value2`.
public var value2: Swift.String?
/// Creates a new `CapabilityType`.
///
/// - Parameters:
/// - value1:
/// - value2:
public init(
value1: Components.Schemas.CapabilityType.Value1Payload? = nil,
value2: Swift.String? = nil
) {
self.value1 = value1
self.value2 = value2
}
public init(from decoder: any Decoder) throws {
var errors: [any Error] = []
do {
self.value1 = try decoder.decodeFromSingleValueContainer()
} catch {
errors.append(error)
}
do {
self.value2 = try decoder.decodeFromSingleValueContainer()
} catch {
errors.append(error)
}
try Swift.DecodingError.verifyAtLeastOneSchemaIsNotNil(
[
self.value1,
self.value2
],
type: Self.self,
codingPath: decoder.codingPath,
errors: errors
)
}
public func encode(to encoder: any Encoder) throws {
try encoder.encodeFirstNonNilValueToSingleValueContainer([
self.value1,
self.value2
])
}
@frozen public enum CapabilityType: String, Codable, Hashable, Sendable, CaseIterable {
case icloud = "ICLOUD"
case inAppPurchase = "IN_APP_PURCHASE"
case gameCenter = "GAME_CENTER"
case pushNotifications = "PUSH_NOTIFICATIONS"
case wallet = "WALLET"
case interAppAudio = "INTER_APP_AUDIO"
case maps = "MAPS"
case associatedDomains = "ASSOCIATED_DOMAINS"
case personalVpn = "PERSONAL_VPN"
case appGroups = "APP_GROUPS"
case healthkit = "HEALTHKIT"
case homekit = "HOMEKIT"
case wirelessAccessoryConfiguration = "WIRELESS_ACCESSORY_CONFIGURATION"
case applePay = "APPLE_PAY"
case dataProtection = "DATA_PROTECTION"
case sirikit = "SIRIKIT"
case networkExtensions = "NETWORK_EXTENSIONS"
case multipath = "MULTIPATH"
case hotSpot = "HOT_SPOT"
case nfcTagReading = "NFC_TAG_READING"
case classkit = "CLASSKIT"
case autofillCredentialProvider = "AUTOFILL_CREDENTIAL_PROVIDER"
case accessWifiInformation = "ACCESS_WIFI_INFORMATION"
case networkCustomProtocol = "NETWORK_CUSTOM_PROTOCOL"
case coremediaHlsLowLatency = "COREMEDIA_HLS_LOW_LATENCY"
case systemExtensionInstall = "SYSTEM_EXTENSION_INSTALL"
case userManagement = "USER_MANAGEMENT"
case appleIdAuth = "APPLE_ID_AUTH"
}
/// - Remark: Generated from `#/components/schemas/CertificateType`.
public struct CertificateType: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/CertificateType/value1`.
@frozen public enum Value1Payload: String, Codable, Hashable, Sendable, CaseIterable {
case applePay = "APPLE_PAY"
case applePayMerchantIdentity = "APPLE_PAY_MERCHANT_IDENTITY"
case applePayPspIdentity = "APPLE_PAY_PSP_IDENTITY"
case applePayRsa = "APPLE_PAY_RSA"
case developerIdKext = "DEVELOPER_ID_KEXT"
case developerIdKextG2 = "DEVELOPER_ID_KEXT_G2"
case developerIdApplication = "DEVELOPER_ID_APPLICATION"
case developerIdApplicationG2 = "DEVELOPER_ID_APPLICATION_G2"
case development = "DEVELOPMENT"
case distribution = "DISTRIBUTION"
case identityAccess = "IDENTITY_ACCESS"
case iosDevelopment = "IOS_DEVELOPMENT"
case iosDistribution = "IOS_DISTRIBUTION"
case macAppDistribution = "MAC_APP_DISTRIBUTION"
case macInstallerDistribution = "MAC_INSTALLER_DISTRIBUTION"
case macAppDevelopment = "MAC_APP_DEVELOPMENT"
case passTypeId = "PASS_TYPE_ID"
case passTypeIdWithNfc = "PASS_TYPE_ID_WITH_NFC"
}
/// - Remark: Generated from `#/components/schemas/CertificateType/value1`.
public var value1: Components.Schemas.CertificateType.Value1Payload?
/// - Remark: Generated from `#/components/schemas/CertificateType/value2`.
public var value2: Swift.String?
/// Creates a new `CertificateType`.
///
/// - Parameters:
/// - value1:
/// - value2:
public init(
value1: Components.Schemas.CertificateType.Value1Payload? = nil,
value2: Swift.String? = nil
) {
self.value1 = value1
self.value2 = value2
}
public init(from decoder: any Decoder) throws {
var errors: [any Error] = []
do {
self.value1 = try decoder.decodeFromSingleValueContainer()
} catch {
errors.append(error)
}
do {
self.value2 = try decoder.decodeFromSingleValueContainer()
} catch {
errors.append(error)
}
try Swift.DecodingError.verifyAtLeastOneSchemaIsNotNil(
[
self.value1,
self.value2
],
type: Self.self,
codingPath: decoder.codingPath,
errors: errors
)
}
public func encode(to encoder: any Encoder) throws {
try encoder.encodeFirstNonNilValueToSingleValueContainer([
self.value1,
self.value2
])
}
@frozen public enum CertificateType: String, Codable, Hashable, Sendable, CaseIterable {
case applePay = "APPLE_PAY"
case applePayMerchantIdentity = "APPLE_PAY_MERCHANT_IDENTITY"
case applePayPspIdentity = "APPLE_PAY_PSP_IDENTITY"
case applePayRsa = "APPLE_PAY_RSA"
case developerIdKext = "DEVELOPER_ID_KEXT"
case developerIdKextG2 = "DEVELOPER_ID_KEXT_G2"
case developerIdApplication = "DEVELOPER_ID_APPLICATION"
case developerIdApplicationG2 = "DEVELOPER_ID_APPLICATION_G2"
case development = "DEVELOPMENT"
case distribution = "DISTRIBUTION"
case identityAccess = "IDENTITY_ACCESS"
case iosDevelopment = "IOS_DEVELOPMENT"
case iosDistribution = "IOS_DISTRIBUTION"
case macAppDistribution = "MAC_APP_DISTRIBUTION"
case macInstallerDistribution = "MAC_INSTALLER_DISTRIBUTION"
case macAppDevelopment = "MAC_APP_DEVELOPMENT"
case passTypeId = "PASS_TYPE_ID"
case passTypeIdWithNfc = "PASS_TYPE_ID_WITH_NFC"
}
/// - Remark: Generated from `#/components/schemas/SubscriptionStatusUrlVersion`.
@frozen public enum SubscriptionStatusUrlVersion: String, Codable, Hashable, Sendable, CaseIterable {
+28
View File
@@ -0,0 +1,28 @@
overlay: 1.0.0
info:
title: Overlay for App Store Connect API
version: 1.0.0
actions:
- target: '$.components.schemas.BundleIdCapabilityCreateRequest.properties.data.properties.relationships'
update:
properties:
capability:
type: object
properties:
data:
type: object
properties:
type:
type: string
enum: [capabilities]
id:
"$ref": "#/components/schemas/CapabilityType"
required: [id, type]
required: [data]
required: [capability]
- target: '$.components.schemas.Device.properties.attributes.properties.deviceClass'
update:
enum: ["APPLE_VISION_PRO"]
- target: '$.components.schemas.BundleIdPlatform'
update:
enum: ["SERVICES"]
-59
View File
@@ -1,59 +0,0 @@
#!/usr/bin/env node
import fs from 'fs';
function makeOpen(enumSchema) {
const copy = structuredClone(enumSchema);
Object.keys(enumSchema).forEach(k => delete enumSchema[k]);
Object.assign(enumSchema, {
anyOf: [
copy,
{ type: 'string' },
]
})
}
function format(schema) {
const schemas = schema.components.schemas;
// this field is required when using the private Xcode API
const capabilityCreateRelationships = schemas.BundleIdCapabilityCreateRequest.properties.data.properties.relationships;
capabilityCreateRelationships.properties.capability = {
type: 'object',
properties: {
data: {
type: 'object',
properties: {
type: {
type: 'string',
enum: ['capabilities'],
},
id: { $ref: '#/components/schemas/CapabilityType' },
},
required: ['id', 'type'],
},
},
required: ['data'],
}
capabilityCreateRelationships.required.push('capability');
// we don't use this but it triggers a deprecation warning. see:
// https://github.com/apple/swift-openapi-generator/issues/715
schemas.App.properties.relationships.properties.inAppPurchases.deprecated = false;
// openapi-generator expects response enums to be exhaustive. Apple's ASC OpenAPI spec
// misses some cases that they do, actually, return.
// https://swiftpackageindex.com/apple/swift-openapi-generator/1.7.2/documentation/swift-openapi-generator/useful-openapi-patterns#Open-enums-and-oneOfs
makeOpen(schemas.BundleIdPlatform);
makeOpen(schemas.CapabilityType);
makeOpen(schemas.CertificateType);
makeOpen(schemas.Device.properties.attributes.properties.deviceClass);
return schema;
}
const text = fs.readFileSync(process.stdin.fd, 'utf8');
const json = JSON.parse(text);
const formatted = format(json);
const formattedText = JSON.stringify(formatted);
console.log(formattedText);
@@ -57,7 +57,7 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {
_type: .bundleIds,
attributes: .init(
name: name,
platform: .init(.ios),
platform: .ios,
identifier: newBundleID
)
)
@@ -105,8 +105,8 @@ public struct DeveloperServicesAddAppOperation: DeveloperServicesOperation {
}
} else {
// DeveloperServices doesn't allow deleting these capabilities
let requiredCapabilities: Set<Components.Schemas.CapabilityType.Value1Payload> = [.inAppPurchase]
if let capType = cap.attributes?.capabilityType?.value1, !requiredCapabilities.contains(capType) {
let requiredCapabilities: Set<Components.Schemas.CapabilityType> = [.inAppPurchase]
if let capType = cap.attributes?.capabilityType, !requiredCapabilities.contains(capType) {
_ = try await context.developerAPIClient
.bundleIdCapabilitiesDeleteInstance(path: .init(id: cap.id))
.noContent
@@ -15,11 +15,11 @@ public struct DeveloperServicesCapability: Sendable, Hashable {
public var settings: [Components.Schemas.CapabilitySetting]?
public init(
_ capabilityType: Components.Schemas.CapabilityType.Value1Payload,
_ capabilityType: Components.Schemas.CapabilityType,
isFree: Bool,
settings: [Components.Schemas.CapabilitySetting]? = nil
) {
self.capabilityType = .init(capabilityType)
self.capabilityType = capabilityType
self.isFree = isFree
self.settings = settings
}
@@ -54,7 +54,7 @@ public struct DeveloperServicesFetchCertificateOperation: DeveloperServicesOpera
_type: .certificates,
attributes: .init(
csrContent: csr.pemString,
certificateType: .init(.development)
certificateType: .development
)
)))
)
@@ -256,27 +256,3 @@ struct LoggingMiddleware: ClientMiddleware {
return (response, body)
}
}
// syntactic sugar to make it nicer to work with `anyOf:` types
public protocol OpenAPIExtensibleEnum {
associatedtype Value1Payload: RawRepresentable<String>, Codable, Hashable, Sendable, CaseIterable
var value1: Value1Payload? { get set }
var value2: String? { get set }
init(value1: Value1Payload?, value2: String?)
}
extension OpenAPIExtensibleEnum {
public var rawValue: String {
value2!
}
public init(_ value: Value1Payload) {
self.init(value1: value, value2: nil)
}
}
extension Components.Schemas.BundleIdPlatform: OpenAPIExtensibleEnum {}
extension Components.Schemas.CapabilityType: OpenAPIExtensibleEnum {}
extension Components.Schemas.CertificateType: OpenAPIExtensibleEnum {}
extension Components.Schemas.Device.AttributesPayload.DeviceClassPayload: OpenAPIExtensibleEnum {}
@@ -27,7 +27,7 @@ public struct DeveloperServicesFetchDeviceOperation: DeveloperServicesOperation
_type: .devices,
attributes: .init(
name: self.context.deviceName,
platform: .init(.ios),
platform: .ios,
udid: self.context.udid
)
)))
+1 -8
View File
@@ -198,14 +198,7 @@ struct DevRunCommand: AsyncParsableCommand {
defer { print() }
do {
try await installer.install(app: output)
} catch let error as CancellationError {
throw error
} catch {
print("\nError: \(error)")
throw ExitCode.failure
}
try await installer.install(app: output)
}
}
+2 -4
View File
@@ -34,11 +34,9 @@ struct InstallCommand: AsyncParsableCommand {
do {
try await installer.install(app: URL(fileURLWithPath: path))
print("\nSuccessfully installed!")
} catch let error as CancellationError {
throw error
} catch {
print("\nError: \(error)")
throw ExitCode.failure
print("\nFailed :(")
print("Error: \(error)")
}
}
}