WIP from the MacBook: apple platform helper for submit, resubmit, release and status
This commit is contained in:
parent
3e4015b686
commit
96c1074701
8 changed files with 169 additions and 57 deletions
|
|
@ -21,13 +21,15 @@ import { allSubscriptions } from '../lib/subscriptions';
|
|||
import { addAction, bindIds, chooseSubmission, EMPTY_DRAFT, labelOf, type ResolveScope, resolveHint, toResolve, latestVersion, NEW_VERSION_FROM, newVersionReq, type PIap, planIapSubmission, type PSub, type SubmitState, versionsOf, willSubmit } from '../lib/review-submit';
|
||||
import { readJournal } from '../lib/upsert';
|
||||
import { type Asc, ascClient, type J } from './asc';
|
||||
import type { ApplePlatform } from '../lib/apple-platform';
|
||||
import { describeReq, execute } from './jsonapi';
|
||||
import { addItem, draftJournalKey, ensureDraft, leaveUnusedDraft, openSubmissions, OtherSubmissionError, resolveRejected, submitWithRetry } from './submission';
|
||||
|
||||
const TAG = 'iap-submit';
|
||||
|
||||
export async function readSubmitState(c: Asc, appId: string, want: string[], o: { appVersionId?: string; also?: string } = {}): Promise<SubmitState> {
|
||||
const appVersions = (await c.all(`/v1/apps/${appId}/appStoreVersions?filter[platform]=IOS&limit=50`)).map((v: J) => ({ id: v.id, versionString: v.attributes.versionString,
|
||||
export async function readSubmitState(c: Asc, appId: string, want: string[], o: { appVersionId?: string; also?: string; platform?: ApplePlatform } = {}): Promise<SubmitState> {
|
||||
const platform = o.platform ?? 'IOS';
|
||||
const appVersions = (await c.all(`/v1/apps/${appId}/appStoreVersions?filter[platform]=${platform}&limit=50`)).map((v: J) => ({ id: v.id, versionString: v.attributes.versionString,
|
||||
state: v.attributes.appVersionState ?? v.attributes.appStoreState }));
|
||||
const iaps: PIap[] = [];
|
||||
for (const p of await c.all(`/v1/apps/${appId}/inAppPurchasesV2?limit=200`)) {
|
||||
|
|
@ -45,10 +47,10 @@ export async function readSubmitState(c: Asc, appId: string, want: string[], o:
|
|||
versions: want.includes(s.attributes.productId) ? versionsOf(await c.all(`/v1/subscriptions/${s.id}/versions?limit=200`)) : [] });
|
||||
}
|
||||
// every open review submission: a draft or one back from App Review is reused, never a second one next to it
|
||||
const open = await openSubmissions(c, appId, o.also);
|
||||
const open = await openSubmissions(c, appId, o.also, platform);
|
||||
const choice = chooseSubmission(open, { appVersionId: o.appVersionId ?? appVersions.find((v: { state: string }) => /REJECTED|INVALID_BINARY/.test(v.state))?.id });
|
||||
const draft: SubmitState['draft'] = choice.action === 'reuse' ? { id: choice.sub.id, state: choice.sub.state, itemVersionIds: choice.sub.items.map(i => i.versionId) } : null;
|
||||
return { appVersions, iaps, subs, groups, draft, open, choice };
|
||||
return { appVersions, iaps, subs, groups, draft, open, choice, platform };
|
||||
}
|
||||
|
||||
/** The requests a run would send: none when nothing is left to submit (seen live: every product already in review),
|
||||
|
|
@ -155,7 +157,7 @@ export async function submitPlanned(ctx: Ctx, c: Asc, o: SubmitOpts): Promise<vo
|
|||
// already in it, and an item the store says is in there already (409) is not added twice
|
||||
let sid = state.draft?.id;
|
||||
let created = false;
|
||||
if (!sid) ({ id: sid, created } = await ensureDraft(c, o.appId, root, tag));
|
||||
if (!sid) ({ id: sid, created } = await ensureDraft(c, o.appId, root, tag, state.platform));
|
||||
try {
|
||||
for (const r of prepare) {
|
||||
if (r.path === '/v1/reviewSubmissions') continue;
|
||||
|
|
@ -175,7 +177,7 @@ export async function submitPlanned(ctx: Ctx, c: Asc, o: SubmitOpts): Promise<vo
|
|||
if (o.retried || e.otherId === '?') throw e;
|
||||
// use the submission the 409 named: read the state again with it and go once more
|
||||
log(tag, `using review submission ${e.otherId} instead`);
|
||||
const again = await readSubmitState(c, o.appId, o.ids, { appVersionId: o.appVersionId ?? plan.appVersion?.id, also: e.otherId });
|
||||
const again = await readSubmitState(c, o.appId, o.ids, { appVersionId: o.appVersionId ?? plan.appVersion?.id, also: e.otherId, platform: state.platform });
|
||||
for (const l of choiceLines(again)) log(tag, l);
|
||||
await submitPlanned(ctx, c, { ...o, state: again, retried: true, quiet: true });
|
||||
return;
|
||||
|
|
@ -201,7 +203,7 @@ export async function submitPlanned(ctx: Ctx, c: Asc, o: SubmitOpts): Promise<vo
|
|||
* cancellable state" for it (seen live) and it does no harm; one with items is named with the cancel command. */
|
||||
function cleanStrayDrafts(root: string, appId: string, state: SubmitState, tag: string): void {
|
||||
if (state.choice?.action !== 'reuse') return;
|
||||
const mine = readJournal(root)[draftJournalKey(appId)]?.id;
|
||||
const mine = readJournal(root)[draftJournalKey(appId, state.platform)]?.id;
|
||||
for (const d of state.choice.strayDrafts) {
|
||||
if (!d.items.length) { log(tag, `draft ${d.id}${d.id === mine ? ' (created by storebound)' : ''}: ${EMPTY_DRAFT}; left as it is`); continue; }
|
||||
warn(tag, `draft ${d.id} (${d.items.length} item(s)) is still open next to ${state.choice.sub.id}; cancel it if it is not needed: storebound apple status --cancel-submission ${d.id}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue