diff --git a/cli/api/wrapped.gen.ts b/cli/api/wrapped.gen.ts index 3252c91..7da7541 100644 --- a/cli/api/wrapped.gen.ts +++ b/cli/api/wrapped.gen.ts @@ -69,6 +69,7 @@ export const WRAPPED: { apple: Record; play: Record; play: Record; play: Record + type === 'gameCenterLeaderboards' ? `/v1/gameCenterLeaderboards/${id}/localizations?limit=200` : `/v1/gameCenterAchievements/${id}/localizations?limit=200`; +const itemsPath = (type: 'gameCenterLeaderboards' | 'gameCenterAchievements', detail: string): string => + type === 'gameCenterLeaderboards' ? `/v1/gameCenterDetails/${detail}/gameCenterLeaderboards?limit=200` : `/v1/gameCenterDetails/${detail}/gameCenterAchievements?limit=200`; + async function withLocs(c: Asc, list: J[], type: 'gameCenterLeaderboards' | 'gameCenterAchievements'): Promise { const out: GcExisting[] = []; - for (const x of list) out.push({ id: x.id, attributes: x.attributes ?? {}, localizations: (await c.all(`/v1/${type}/${x.id}/localizations?limit=200`)).map((l: J) => ({ id: l.id, attributes: l.attributes ?? {} })) }); + for (const x of list) out.push({ id: x.id, attributes: x.attributes ?? {}, localizations: (await c.all(locsPath(type, x.id))).map((l: J) => ({ id: l.id, attributes: l.attributes ?? {} })) }); return out; } @@ -100,12 +106,12 @@ export async function run(ctx: Ctx): Promise { log(TAG, `Game Center switched on for version ${s.version.versionString}`); } for (const p of plan) { - const type = p.kind === 'leaderboard' ? 'gameCenterLeaderboards' : 'gameCenterAchievements'; + const type = p.kind === 'leaderboard' ? 'gameCenterLeaderboards' as const : 'gameCenterAchievements' as const; const locType = p.kind === 'leaderboard' ? 'gameCenterLeaderboardLocalizations' : 'gameCenterAchievementLocalizations'; const parentRel = p.kind === 'leaderboard' ? 'gameCenterLeaderboard' : 'gameCenterAchievement'; let id = p.storeId; if (p.action === 'create') { - const find = async () => (await c.all(`/v1/gameCenterDetails/${detail}/${type}?limit=200`)).find((x: J) => x.attributes?.vendorIdentifier === p.id)?.id ?? null; + const find = async () => (await c.all(itemsPath(type, detail!))).find((x: J) => x.attributes?.vendorIdentifier === p.id)?.id ?? null; id = (await createOnce({ what: `${p.kind} ${p.id}`, tag: TAG, unique: true, find, create: async () => (await c.asc('POST', `/v1/${type}`, { data: { type, attributes: { ...p.attributes, vendorIdentifier: p.id }, relationships: { gameCenterDetail: { data: { type: 'gameCenterDetails', id: detail } } } } })).data.id as string })).value; log(TAG, `${p.kind} ${p.id}: created`); @@ -118,7 +124,7 @@ export async function run(ctx: Ctx): Promise { if (l.action === 'create') { const pid = id!; await createOnce({ what: `${p.kind} ${p.id} ${l.locale}`, tag: TAG, unique: true, - find: async () => (await c.all(`/v1/${type}/${pid}/localizations?limit=200`)).find((x: J) => x.attributes?.locale === l.locale)?.id ?? null, + find: async () => (await c.all(locsPath(type, pid))).find((x: J) => x.attributes?.locale === l.locale)?.id ?? null, create: async () => (await c.asc('POST', `/v1/${locType}`, { data: { type: locType, attributes: { locale: l.locale, ...l.attributes }, relationships: { [parentRel]: { data: { type, id: pid } } } } })).data.id as string }); log(TAG, `${p.kind} ${p.id} ${l.locale}: created`); } else if (l.action === 'update') { diff --git a/docs/api-coverage.md b/docs/api-coverage.md index b71b200..22354bd 100644 --- a/docs/api-coverage.md +++ b/docs/api-coverage.md @@ -12,7 +12,7 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co | API | operations | GET | other | wrapped by a command | owner only | |---|---:|---:|---:|---:|---:| -| App Store Connect API 4.5.1 | 1303 | 826 | 477 | 210 | 166 | +| App Store Connect API 4.5.1 | 1303 | 826 | 477 | 218 | 166 | | Google Play Android Developer API v3 (revision 20261008) | 145 | 45 | 100 | 35 | 49 | | Google Play Developer Reporting API v1beta1 (revision 20261008) | 25 | 15 | 10 | 6 | 0 | @@ -384,7 +384,7 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co | `appStoreVersions_customerReviews_getToManyRelated` | GET | `/v1/appStoreVersions/{id}/customerReviews` | read | | | `appStoreVersions_customerReviews_getToManyRelationship` | GET | `/v1/appStoreVersions/{id}/relationships/customerReviews` | read | | | `appStoreVersions_deleteInstance` | DELETE | `/v1/appStoreVersions/{id}` | owner only (typed confirm) | | -| `appStoreVersions_gameCenterAppVersion_getToOneRelated` | GET | `/v1/appStoreVersions/{id}/gameCenterAppVersion` | read | | +| `appStoreVersions_gameCenterAppVersion_getToOneRelated` | GET | `/v1/appStoreVersions/{id}/gameCenterAppVersion` | read | apple/game-center | | `appStoreVersions_gameCenterAppVersion_getToOneRelationship` | GET | `/v1/appStoreVersions/{id}/relationships/gameCenterAppVersion` | read | | | `appStoreVersions_getInstance` | GET | `/v1/appStoreVersions/{id}` | read | apple/listing | | `appStoreVersions_routingAppCoverage_getToOneRelated` | GET | `/v1/appStoreVersions/{id}/routingAppCoverage` | read | | @@ -454,7 +454,7 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co | `apps_customerReviews_getToManyRelationship` | GET | `/v1/apps/{id}/relationships/customerReviews` | read | | | `apps_endUserLicenseAgreement_getToOneRelated` | GET | `/v1/apps/{id}/endUserLicenseAgreement` | read | | | `apps_endUserLicenseAgreement_getToOneRelationship` | GET | `/v1/apps/{id}/relationships/endUserLicenseAgreement` | read | | -| `apps_gameCenterDetail_getToOneRelated` | GET | `/v1/apps/{id}/gameCenterDetail` | read | | +| `apps_gameCenterDetail_getToOneRelated` | GET | `/v1/apps/{id}/gameCenterDetail` | read | apple/game-center | | `apps_gameCenterDetail_getToOneRelationship` | GET | `/v1/apps/{id}/relationships/gameCenterDetail` | read | | | `apps_gameCenterEnabledVersions_getToManyRelated` | GET | `/v1/apps/{id}/gameCenterEnabledVersions` | read | | | `apps_gameCenterEnabledVersions_getToManyRelationship` | GET | `/v1/apps/{id}/relationships/gameCenterEnabledVersions` | read | | @@ -817,7 +817,7 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co | `gameCenterAchievements_groupAchievement_getToOneRelated` | GET | `/v1/gameCenterAchievements/{id}/groupAchievement` | read | | | `gameCenterAchievements_groupAchievement_getToOneRelationship` | GET | `/v1/gameCenterAchievements/{id}/relationships/groupAchievement` | read | | | `gameCenterAchievements_groupAchievement_updateToOneRelationship` | PATCH | `/v1/gameCenterAchievements/{id}/relationships/groupAchievement` | write (dry by default) | | -| `gameCenterAchievements_localizations_getToManyRelated` | GET | `/v1/gameCenterAchievements/{id}/localizations` | read | | +| `gameCenterAchievements_localizations_getToManyRelated` | GET | `/v1/gameCenterAchievements/{id}/localizations` | read | apple/game-center | | `gameCenterAchievements_localizations_getToManyRelationship` | GET | `/v1/gameCenterAchievements/{id}/relationships/localizations` | read | | | `gameCenterAchievements_releases_getToManyRelated` | GET | `/v1/gameCenterAchievements/{id}/releases` | read | | | `gameCenterAchievements_releases_getToManyRelationship` | GET | `/v1/gameCenterAchievements/{id}/relationships/releases` | read | | @@ -868,7 +868,7 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co | `gameCenterAppVersions_compatibilityVersions_deleteToManyRelationship` | DELETE | `/v1/gameCenterAppVersions/{id}/relationships/compatibilityVersions` | owner only (typed confirm) | | | `gameCenterAppVersions_compatibilityVersions_getToManyRelated` | GET | `/v1/gameCenterAppVersions/{id}/compatibilityVersions` | read | | | `gameCenterAppVersions_compatibilityVersions_getToManyRelationship` | GET | `/v1/gameCenterAppVersions/{id}/relationships/compatibilityVersions` | read | | -| `gameCenterAppVersions_createInstance` | POST | `/v1/gameCenterAppVersions` | write (dry by default) | | +| `gameCenterAppVersions_createInstance` | POST | `/v1/gameCenterAppVersions` | write (dry by default) | apple/game-center | | `gameCenterAppVersions_getInstance` | GET | `/v1/gameCenterAppVersions/{id}` | read | | | `gameCenterAppVersions_updateInstance` | PATCH | `/v1/gameCenterAppVersions/{id}` | write (dry by default) | | | **gameCenterChallengeImages** (4) | | | | | @@ -916,11 +916,11 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co | `gameCenterDetails_challengeReleases_getToManyRelationship` | GET | `/v1/gameCenterDetails/{id}/relationships/challengeReleases` | read | | | `gameCenterDetails_challengesMinimumPlatformVersions_replaceToManyRelationship` | PATCH | `/v1/gameCenterDetails/{id}/relationships/challengesMinimumPlatformVersions` | write (dry by default) | | | `gameCenterDetails_classicMatchmakingRequests_getMetrics` | GET | `/v1/gameCenterDetails/{id}/metrics/classicMatchmakingRequests` | read | | -| `gameCenterDetails_createInstance` | POST | `/v1/gameCenterDetails` | write (dry by default) | | +| `gameCenterDetails_createInstance` | POST | `/v1/gameCenterDetails` | write (dry by default) | apple/game-center | | `gameCenterDetails_gameCenterAchievementsV2_getToManyRelated` | GET | `/v1/gameCenterDetails/{id}/gameCenterAchievementsV2` | read | | | `gameCenterDetails_gameCenterAchievementsV2_getToManyRelationship` | GET | `/v1/gameCenterDetails/{id}/relationships/gameCenterAchievementsV2` | read | | | `gameCenterDetails_gameCenterAchievementsV2_replaceToManyRelationship` | PATCH | `/v1/gameCenterDetails/{id}/relationships/gameCenterAchievementsV2` | write (dry by default) | | -| `gameCenterDetails_gameCenterAchievements_getToManyRelated` | GET | `/v1/gameCenterDetails/{id}/gameCenterAchievements` | read | | +| `gameCenterDetails_gameCenterAchievements_getToManyRelated` | GET | `/v1/gameCenterDetails/{id}/gameCenterAchievements` | read | apple/game-center | | `gameCenterDetails_gameCenterAchievements_getToManyRelationship` | GET | `/v1/gameCenterDetails/{id}/relationships/gameCenterAchievements` | read | | | `gameCenterDetails_gameCenterAchievements_replaceToManyRelationship` | PATCH | `/v1/gameCenterDetails/{id}/relationships/gameCenterAchievements` | write (dry by default) | | | `gameCenterDetails_gameCenterActivities_getToManyRelated` | GET | `/v1/gameCenterDetails/{id}/gameCenterActivities` | read | | @@ -940,7 +940,7 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co | `gameCenterDetails_gameCenterLeaderboardsV2_getToManyRelated` | GET | `/v1/gameCenterDetails/{id}/gameCenterLeaderboardsV2` | read | | | `gameCenterDetails_gameCenterLeaderboardsV2_getToManyRelationship` | GET | `/v1/gameCenterDetails/{id}/relationships/gameCenterLeaderboardsV2` | read | | | `gameCenterDetails_gameCenterLeaderboardsV2_replaceToManyRelationship` | PATCH | `/v1/gameCenterDetails/{id}/relationships/gameCenterLeaderboardsV2` | write (dry by default) | | -| `gameCenterDetails_gameCenterLeaderboards_getToManyRelated` | GET | `/v1/gameCenterDetails/{id}/gameCenterLeaderboards` | read | | +| `gameCenterDetails_gameCenterLeaderboards_getToManyRelated` | GET | `/v1/gameCenterDetails/{id}/gameCenterLeaderboards` | read | apple/game-center | | `gameCenterDetails_gameCenterLeaderboards_getToManyRelationship` | GET | `/v1/gameCenterDetails/{id}/relationships/gameCenterLeaderboards` | read | | | `gameCenterDetails_gameCenterLeaderboards_replaceToManyRelationship` | PATCH | `/v1/gameCenterDetails/{id}/relationships/gameCenterLeaderboards` | write (dry by default) | | | `gameCenterDetails_getInstance` | GET | `/v1/gameCenterDetails/{id}` | read | | @@ -1106,7 +1106,7 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co | `gameCenterLeaderboards_groupLeaderboard_getToOneRelated` | GET | `/v1/gameCenterLeaderboards/{id}/groupLeaderboard` | read | | | `gameCenterLeaderboards_groupLeaderboard_getToOneRelationship` | GET | `/v1/gameCenterLeaderboards/{id}/relationships/groupLeaderboard` | read | | | `gameCenterLeaderboards_groupLeaderboard_updateToOneRelationship` | PATCH | `/v1/gameCenterLeaderboards/{id}/relationships/groupLeaderboard` | write (dry by default) | | -| `gameCenterLeaderboards_localizations_getToManyRelated` | GET | `/v1/gameCenterLeaderboards/{id}/localizations` | read | | +| `gameCenterLeaderboards_localizations_getToManyRelated` | GET | `/v1/gameCenterLeaderboards/{id}/localizations` | read | apple/game-center | | `gameCenterLeaderboards_localizations_getToManyRelationship` | GET | `/v1/gameCenterLeaderboards/{id}/relationships/localizations` | read | | | `gameCenterLeaderboards_releases_getToManyRelated` | GET | `/v1/gameCenterLeaderboards/{id}/releases` | read | | | `gameCenterLeaderboards_releases_getToManyRelationship` | GET | `/v1/gameCenterLeaderboards/{id}/relationships/releases` | read | |