idempotency: apple listing findOrCreate / createOnce, play listing re-plan in the edit, data-safety hash, twice-run tests for the last open rows
This commit is contained in:
parent
d5bc7b8889
commit
a2009fa7ac
12 changed files with 368 additions and 54 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -34,6 +34,18 @@
|
||||||
with zero writes on the second run, a crash in the middle of a screenshot set, IAP and subscription creates whose
|
with zero writes on the second run, a crash in the middle of a screenshot set, IAP and subscription creates whose
|
||||||
answer is lost, 409 duplicates, the list lag after a crash, Play edit error paths and an unclear commit, the lock.
|
answer is lost, 409 duplicates, the list lag after a crash, Play edit error paths and an unclear commit, the lock.
|
||||||
Pitfall 9 in `docs/pitfalls.md` and the store-pitfalls skill.
|
Pitfall 9 in `docs/pitfalls.md` and the store-pitfalls skill.
|
||||||
|
- The last open rows are closed (`docs/idempotency.md` has none left):
|
||||||
|
- `apple listing`: the App Store version is created through `findOrCreate` (a fresh look right before the create,
|
||||||
|
the journal for the list lag, a lost answer looks first); localizations through `createOnce` (409 = found, then
|
||||||
|
only the differing fields are PATCHed); unchanged localizations and an attached build are left alone.
|
||||||
|
- `play listing`: compares again inside the write edit and PUTs only differing details and languages; nothing left
|
||||||
|
to change = the edit is deleted, not committed.
|
||||||
|
- `apple appinfo`: categories, age rating, content rights compared with the live values, only differences PATCHed.
|
||||||
|
- `play data-safety`: Play cannot read the form back, so the sha256 of the last uploaded CSV is kept in
|
||||||
|
`.storebound/data-safety.sha256`; the same CSV is not sent again unless `--force` (MCP `force`).
|
||||||
|
- Twice-run tests for `apple listing` (plus a lost version create and a 409 localization), `play listing` (plus a
|
||||||
|
store that became current before the edit), `apple appinfo`, `play data-safety`, `apple promoted`,
|
||||||
|
`apple win-back`, `apple preorder`, `apple testflight testers`, `play upload` and `prices import` (Play).
|
||||||
|
|
||||||
- Faster `shots capture` (web) and `shots render` (a 22-language game took about 50 min to capture, serially, with a
|
- Faster `shots capture` (web) and `shots render` (a 22-language game took about 50 min to capture, serially, with a
|
||||||
new context and a full game boot per frame):
|
new context and a full game boot per frame):
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ export const WRAPPED: { apple: Record<string, string>; play: Record<string, stri
|
||||||
'appStoreVersions_build_getToOneRelated': 'apple/listing validate',
|
'appStoreVersions_build_getToOneRelated': 'apple/listing validate',
|
||||||
'appStoreVersions_build_updateToOneRelationship': 'apple/listing',
|
'appStoreVersions_build_updateToOneRelationship': 'apple/listing',
|
||||||
'appStoreVersions_createInstance': 'apple/listing',
|
'appStoreVersions_createInstance': 'apple/listing',
|
||||||
|
'appStoreVersions_getInstance': 'apple/listing',
|
||||||
'appStoreVersions_updateInstance': 'apple/listing',
|
'appStoreVersions_updateInstance': 'apple/listing',
|
||||||
'apps_analyticsReportRequests_getToManyRelated': 'analytics',
|
'apps_analyticsReportRequests_getToManyRelated': 'analytics',
|
||||||
'apps_appAvailabilityV2_getToOneRelated': 'apple/appinfo apple/preorder validate',
|
'apps_appAvailabilityV2_getToOneRelated': 'apple/appinfo apple/preorder validate',
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,13 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
||||||
import { type AppleCopy, parseAppStoreListing } from '../lib/copy';
|
import { type AppleCopy, parseAppStoreListing } from '../lib/copy';
|
||||||
import { compactDiff } from '../lib/diff';
|
import { compactDiff } from '../lib/diff';
|
||||||
import { mergeAppleListing, overLimits } from '../lib/listing-pull';
|
import { mergeAppleListing, overLimits } from '../lib/listing-pull';
|
||||||
import { counts, draftReason, draftSections, type ItemPlan, itemLines, planLocales, planVersion, short, type Skipped, type VersionPlan } from '../lib/listing-plan';
|
import { counts, draftReason, draftSections, type ItemPlan, itemLines, planItem, planLocales, planVersion, short, type Skipped, type VersionPlan } from '../lib/listing-plan';
|
||||||
|
import { createOnce, findOrCreate, getById } from '../lib/upsert';
|
||||||
import { appleName } from '../lib/config';
|
import { appleName } from '../lib/config';
|
||||||
import type { Ctx } from '../lib/ctx';
|
import type { Ctx } from '../lib/ctx';
|
||||||
import { confirm, need } from '../lib/ctx';
|
import { confirm, need } from '../lib/ctx';
|
||||||
import { done, log, printJson, warn } from '../lib/log';
|
import { done, log, printJson, warn } from '../lib/log';
|
||||||
import { ascClient, type J } from './asc';
|
import { ascClient, EDITABLE, type J } from './asc';
|
||||||
|
|
||||||
export function readAppleCopy(ctx: Ctx) {
|
export function readAppleCopy(ctx: Ctx) {
|
||||||
const { config, resolve } = ctx.loaded;
|
const { config, resolve } = ctx.loaded;
|
||||||
|
|
@ -156,15 +157,21 @@ export function listingPlanLines(p: AppleListingPlan): string[] {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function applyLocales(c: Asc, type: string, parentRel: string, parentType: string, parentId: string, plan: ItemPlan[]): Promise<void> {
|
async function applyLocales(c: Asc, type: string, parentRel: string, parentType: string, parentId: string, listPath: string, plan: ItemPlan[]): Promise<void> {
|
||||||
|
const patch = async (key: string, id: string, changes: ItemPlan['changes']) => {
|
||||||
|
await c.asc('PATCH', `/v1/${type}/${id}`, { data: { type, id, attributes: Object.fromEntries(changes.map(ch => [ch.field, ch.to ?? ''])) } });
|
||||||
|
log('apple', `${type} ${key}: updated ${changes.map(ch => ch.field).join(', ')}`);
|
||||||
|
};
|
||||||
for (const l of plan) {
|
for (const l of plan) {
|
||||||
if (l.action === 'create') {
|
if (l.action === 'create') {
|
||||||
await c.asc('POST', `/v1/${type}`, { data: { type, attributes: { locale: l.key, ...l.attributes }, relationships: { [parentRel]: { data: { type: parentType, id: parentId } } } } });
|
// a locale is unique per parent: a 409 (or a lost answer) finds the existing one, which is then updated, never created twice
|
||||||
log('apple', `${type} ${l.key}: created`);
|
const made = await createOnce<J>({ what: `${type} ${l.key}`, tag: 'apple', unique: true,
|
||||||
} else if (l.action === 'update') {
|
find: async () => (await c.all(`${listPath}?limit=200`)).find((x: J) => x.attributes.locale === l.key) ?? null,
|
||||||
await c.asc('PATCH', `/v1/${type}/${l.id}`, { data: { type, id: l.id, attributes: Object.fromEntries(l.changes.map(ch => [ch.field, ch.to ?? ''])) } });
|
create: async () => (await c.asc('POST', `/v1/${type}`, { data: { type, attributes: { locale: l.key, ...l.attributes }, relationships: { [parentRel]: { data: { type: parentType, id: parentId } } } } })).data });
|
||||||
log('apple', `${type} ${l.key}: updated ${l.changes.map(ch => ch.field).join(', ')}`);
|
if (made.created) { log('apple', `${type} ${l.key}: created`); continue; }
|
||||||
}
|
const again = planItem(l.key, { id: made.value.id, attributes: made.value.attributes ?? {} }, l.attributes);
|
||||||
|
if (again.action === 'update') await patch(l.key, made.value.id, again.changes);
|
||||||
|
} else if (l.action === 'update') await patch(l.key, l.id!, l.changes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,9 +196,21 @@ export async function run(ctx: Ctx): Promise<void> {
|
||||||
const vp = p.versionPlan;
|
const vp = p.versionPlan;
|
||||||
let versionId = vp.id;
|
let versionId = vp.id;
|
||||||
if (vp.action === 'create') {
|
if (vp.action === 'create') {
|
||||||
versionId = (await c.asc('POST', '/v1/appStoreVersions', { data: { type: 'appStoreVersions',
|
// look again right before the create (another run, or a lost answer), then the journal for the list lag
|
||||||
attributes: Object.fromEntries(Object.entries(vp.attributes)), relationships: { app: { data: { type: 'apps', id: appId } } } } })).data.id;
|
const made = await findOrCreate<J>({ what: `App Store version ${version}`, tag: 'apple', unique: true,
|
||||||
log('apple', `version ${version} created`);
|
find: async () => (await c.all(`/v1/apps/${appId}/appStoreVersions?filter[platform]=IOS&limit=50`))
|
||||||
|
.find((x: J) => x.attributes.versionString === version && EDITABLE.has(x.attributes.appVersionState ?? x.attributes.appStoreState)) ?? null,
|
||||||
|
journal: { root, key: `apple:${appId}:version:IOS:${version}`, byId: id => getById(c.asc, `/v1/appStoreVersions/${id}`) as Promise<J | null>, idOf: v => v.id },
|
||||||
|
create: async () => (await c.asc('POST', '/v1/appStoreVersions', { data: { type: 'appStoreVersions',
|
||||||
|
attributes: Object.fromEntries(Object.entries(vp.attributes)), relationships: { app: { data: { type: 'apps', id: appId } } } } })).data });
|
||||||
|
versionId = made.value.id;
|
||||||
|
if (made.created) log('apple', `version ${version} created`);
|
||||||
|
else {
|
||||||
|
const { platform: _p, ...want } = vp.attributes;
|
||||||
|
const again = planItem(version, { id: versionId!, attributes: made.value.attributes ?? {} }, want);
|
||||||
|
if (again.action === 'update') await c.asc('PATCH', `/v1/appStoreVersions/${versionId}`, { data: { type: 'appStoreVersions', id: versionId, attributes: Object.fromEntries(again.changes.map(ch => [ch.field, ch.to])) } });
|
||||||
|
log('apple', `version ${version} exists already (an earlier run made it): using it${again.action === 'update' ? `, updated ${again.changes.map(ch => ch.field).join(', ')}` : ''}`);
|
||||||
|
}
|
||||||
} else if (vp.action === 'update') {
|
} else if (vp.action === 'update') {
|
||||||
await c.asc('PATCH', `/v1/appStoreVersions/${versionId}`, { data: { type: 'appStoreVersions', id: versionId, attributes: Object.fromEntries(vp.changes.map(ch => [ch.field, ch.to])) } });
|
await c.asc('PATCH', `/v1/appStoreVersions/${versionId}`, { data: { type: 'appStoreVersions', id: versionId, attributes: Object.fromEntries(vp.changes.map(ch => [ch.field, ch.to])) } });
|
||||||
log('apple', `version: ${vp.changes.map(ch => `${ch.field} ${ch.from ?? '(none)'} -> ${ch.to}`).join(', ')}`);
|
log('apple', `version: ${vp.changes.map(ch => `${ch.field} ${ch.from ?? '(none)'} -> ${ch.to}`).join(', ')}`);
|
||||||
|
|
@ -200,8 +219,9 @@ export async function run(ctx: Ctx): Promise<void> {
|
||||||
await c.asc('PATCH', `/v1/appStoreVersions/${versionId}/relationships/build`, { data: { type: 'builds', id: p.build.id } });
|
await c.asc('PATCH', `/v1/appStoreVersions/${versionId}/relationships/build`, { data: { type: 'builds', id: p.build.id } });
|
||||||
log('apple', `build ${version} (${p.build.number}) attached`);
|
log('apple', `build ${version} (${p.build.number}) attached`);
|
||||||
}
|
}
|
||||||
await applyLocales(c, 'appInfoLocalizations', 'appInfo', 'appInfos', p.appInfo.id, p.appInfo.locales);
|
await applyLocales(c, 'appInfoLocalizations', 'appInfo', 'appInfos', p.appInfo.id, `/v1/appInfos/${p.appInfo.id}/appInfoLocalizations`, p.appInfo.locales);
|
||||||
const vl = p.versionLocales ?? planLocales(await c.all(`/v1/appStoreVersions/${versionId}/appStoreVersionLocalizations?limit=200`), p.wanted);
|
const vlPath = `/v1/appStoreVersions/${versionId}/appStoreVersionLocalizations`;
|
||||||
await applyLocales(c, 'appStoreVersionLocalizations', 'appStoreVersion', 'appStoreVersions', versionId!, vl);
|
const vl = p.versionLocales ?? planLocales(await c.all(`${vlPath}?limit=200`), p.wanted);
|
||||||
|
await applyLocales(c, 'appStoreVersionLocalizations', 'appStoreVersion', 'appStoreVersions', versionId!, vlPath, vl);
|
||||||
done('apple', 'listing done');
|
done('apple', 'listing done');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ const COMMANDS: Record<string, [() => Promise<Mod>, string]> = {
|
||||||
'play subscriptions': [() => import('./play/subscriptions'), 'auto-renewable subscriptions: listings, base plan, regional prices, intro offer, activate (--csv prices sheet; asks first)'],
|
'play subscriptions': [() => import('./play/subscriptions'), 'auto-renewable subscriptions: listings, base plan, regional prices, intro offer, activate (--csv prices sheet; asks first)'],
|
||||||
'play listing': [() => import('./play/listing'), 'app details + title / short / full description per language; pull [--write]: live listings back into the listing file (diff first)'],
|
'play listing': [() => import('./play/listing'), 'app details + title / short / full description per language; pull [--write]: live listings back into the listing file (diff first)'],
|
||||||
'play images': [() => import('./play/images'), 'icon, feature graphic, phone / 7" / 10" screenshots per language; --variant <id>'],
|
'play images': [() => import('./play/images'), 'icon, feature graphic, phone / 7" / 10" screenshots per language; --variant <id>'],
|
||||||
'play data-safety': [() => import('./play/data-safety'), 'Data safety form (CSV import through the API)'],
|
'play data-safety': [() => import('./play/data-safety'), '[--force] Data safety form (CSV import through the API; skipped when unchanged since the last upload)'],
|
||||||
'play release': [() => import('./play/release'), 'upload an AAB and put it on tracks with release notes'],
|
'play release': [() => import('./play/release'), 'upload an AAB and put it on tracks with release notes'],
|
||||||
'play build': [() => import('./play/build'), 'gradle bundleRelease (Flutter: flutter build appbundle) with the next free versionCode and the upload key from env / .storebound; --dry'],
|
'play build': [() => import('./play/build'), 'gradle bundleRelease (Flutter: flutter build appbundle) with the next free versionCode and the upload key from env / .storebound; --dry'],
|
||||||
'play upload': [() => import('./play/upload'), 'upload an AAB to a testing track (--track internal|alpha|beta), versionCode checked first; --dry read-only, asks first'],
|
'play upload': [() => import('./play/upload'), 'upload an AAB to a testing track (--track internal|alpha|beta), versionCode checked first; --dry read-only, asks first'],
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,8 @@ export const TOOLS: ToolDef[] = [
|
||||||
props: { only, csv: { type: 'string', description: 'Prices CSV with rows for subscription ids' } },
|
props: { only, csv: { type: 'string', description: 'Prices CSV with rows for subscription ids' } },
|
||||||
args: i => [...opt('only', i.only), ...opt('csv', i.csv)] },
|
args: i => [...opt('only', i.only), ...opt('csv', i.csv)] },
|
||||||
{ name: 'play_data_safety', title: 'Push Play Data safety', command: ['play', 'data-safety'], write: true, destructive: true, network: true, idempotent: true,
|
{ name: 'play_data_safety', title: 'Push Play Data safety', command: ['play', 'data-safety'], write: true, destructive: true, network: true, idempotent: true,
|
||||||
description: 'Replace the whole Play Data safety form with the answers from the config (CSV import). dry_run prints the CSV.' },
|
description: 'Replace the whole Play Data safety form with the answers from the config (CSV import). Skipped when the CSV equals the last upload of this project (hash in .storebound/; force: true sends it anyway). dry_run prints the CSV.',
|
||||||
|
props: { force: { type: 'boolean', default: false, description: 'Upload even when the CSV equals the last upload (after a manual change in Play Console)' } }, args: i => flag('force', i.force) },
|
||||||
{ name: 'play_release_testing', title: 'Release to a Play testing track', command: ['play', 'release'], write: true, network: true,
|
{ name: 'play_release_testing', title: 'Release to a Play testing track', command: ['play', 'release'], write: true, network: true,
|
||||||
description: 'Upload an AAB (or reuse a versionCode) to a TESTING track (internal, alpha, beta) with release notes. Production is not available here.',
|
description: 'Upload an AAB (or reuse a versionCode) to a TESTING track (internal, alpha, beta) with release notes. Production is not available here.',
|
||||||
props: { aab: { type: 'string', description: 'Path to the .aab' }, version_code: { type: 'integer', minimum: 1 },
|
props: { aab: { type: 'string', description: 'Path to the .aab' }, version_code: { type: 'integer', minimum: 1 },
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
// Play Data safety form through applications.dataSafety (CSV import; replaces every earlier answer).
|
// Play Data safety form through applications.dataSafety (CSV import; replaces every earlier answer).
|
||||||
// storebound play data-safety [--csv out.csv] [--dry]
|
// storebound play data-safety [--csv out.csv] [--dry] [--force]
|
||||||
// Answers come from `dataSafety` in storebound.config.ts. --dry only writes / prints the CSV.
|
// Answers come from `dataSafety` in storebound.config.ts. --dry only writes / prints the CSV.
|
||||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
// Play cannot read the form back, so a run compares with what this project uploaded last: the sha256 of that CSV
|
||||||
|
// (per package) is kept in .storebound/data-safety.sha256 (gitignored). The same CSV is not sent again; --force sends it
|
||||||
|
// anyway (e.g. after the form was changed in Play Console by hand).
|
||||||
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
import type { Ctx } from '../lib/ctx';
|
import type { Ctx } from '../lib/ctx';
|
||||||
import { need } from '../lib/ctx';
|
import { need } from '../lib/ctx';
|
||||||
|
|
@ -10,6 +13,27 @@ import { DATA_SAFETY_UPLOADED } from '../lib/declarations';
|
||||||
import { done, log } from '../lib/log';
|
import { done, log } from '../lib/log';
|
||||||
import { playClient } from './client';
|
import { playClient } from './client';
|
||||||
|
|
||||||
|
export const DATA_SAFETY_HASH = '.storebound/data-safety.sha256';
|
||||||
|
|
||||||
|
/** sha256 of the CSV for one package. Pure. */
|
||||||
|
export const dataSafetyHash = (pkg: string, csv: string): string => new Bun.CryptoHasher('sha256').update(`${pkg}\n${csv}`).digest('hex');
|
||||||
|
|
||||||
|
/** The hash of the last upload of this package, null when none is recorded. */
|
||||||
|
export function lastUpload(root: string, pkg: string): { sha256: string; at: string } | null {
|
||||||
|
const f = join(root, DATA_SAFETY_HASH);
|
||||||
|
if (!existsSync(f)) return null;
|
||||||
|
try { return (JSON.parse(readFileSync(f, 'utf8')) as Record<string, { sha256: string; at: string }>)[pkg] ?? null; } catch { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
function rememberUpload(root: string, pkg: string, sha256: string): void {
|
||||||
|
const f = join(root, DATA_SAFETY_HASH);
|
||||||
|
let all: Record<string, { sha256: string; at: string }> = {};
|
||||||
|
try { if (existsSync(f)) all = JSON.parse(readFileSync(f, 'utf8')); } catch { all = {}; }
|
||||||
|
all[pkg] = { sha256, at: new Date().toISOString() };
|
||||||
|
mkdirSync(join(root, '.storebound'), { recursive: true });
|
||||||
|
writeFileSync(f, JSON.stringify(all, null, 2) + '\n');
|
||||||
|
}
|
||||||
|
|
||||||
export async function run(ctx: Ctx): Promise<void> {
|
export async function run(ctx: Ctx): Promise<void> {
|
||||||
const { config, root, resolve } = ctx.loaded;
|
const { config, root, resolve } = ctx.loaded;
|
||||||
const csv = dataSafetyCsv(need(config.dataSafety, 'dataSafety'));
|
const csv = dataSafetyCsv(need(config.dataSafety, 'dataSafety'));
|
||||||
|
|
@ -17,10 +41,25 @@ export async function run(ctx: Ctx): Promise<void> {
|
||||||
if (out) { writeFileSync(resolve(out), csv); log('play', `wrote ${out}`); }
|
if (out) { writeFileSync(resolve(out), csv); log('play', `wrote ${out}`); }
|
||||||
const types = Object.keys(config.dataSafety!.data);
|
const types = Object.keys(config.dataSafety!.data);
|
||||||
log('play', `data safety: ${types.length} data types declared (${types.join(', ') || 'none'})`);
|
log('play', `data safety: ${types.length} data types declared (${types.join(', ') || 'none'})`);
|
||||||
if (ctx.args.has('dry')) { if (!out) process.stdout.write(csv); return; }
|
const pkg = need(config.play?.packageName, 'play.packageName');
|
||||||
const play = await playClient(root, need(config.play?.packageName, 'play.packageName'));
|
const hash = dataSafetyHash(pkg, csv);
|
||||||
|
const last = lastUpload(root, pkg);
|
||||||
|
const same = last?.sha256 === hash;
|
||||||
|
if (ctx.args.has('dry')) {
|
||||||
|
if (!out) process.stdout.write(csv);
|
||||||
|
log('play', same ? `the same CSV was uploaded ${last!.at.slice(0, 16).replace('T', ' ')} UTC: a real run sends nothing (--force sends it again)` : 'a real run uploads it (it differs from the last upload, or none is recorded)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (same && !ctx.args.has('force')) {
|
||||||
|
done('play', `data safety unchanged since the upload of ${last!.at.slice(0, 16).replace('T', ' ')} UTC: nothing sent (--force sends it again, e.g. after a change in Play Console)`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const play = await playClient(root, pkg);
|
||||||
await play.call('POST', `${play.API}/dataSafety`, { safetyLabels: csv });
|
await play.call('POST', `${play.API}/dataSafety`, { safetyLabels: csv });
|
||||||
// Play cannot read the form back: keep what went up, so the desktop app can show what changed since (gitignored).
|
// keep what went up: the hash skips the next identical upload, the CSV lets the desktop app show what changed since
|
||||||
try { mkdirSync(join(root, '.storebound'), { recursive: true }); writeFileSync(join(root, DATA_SAFETY_UPLOADED), csv); } catch { /* the upload itself worked */ }
|
try {
|
||||||
|
rememberUpload(root, pkg, hash);
|
||||||
|
writeFileSync(join(root, DATA_SAFETY_UPLOADED), csv);
|
||||||
|
} catch { /* the upload itself worked */ }
|
||||||
done('play', `data safety updated (${csv.split('\n').length - 2} rows)`);
|
done('play', `data safety updated (${csv.split('\n').length - 2} rows)`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,16 +140,24 @@ export async function run(ctx: Ctx): Promise<void> {
|
||||||
if (dry) { done('play', `dry run: ${p.changes ? `${p.changes} change(s)` : 'nothing to change'}; read-only, nothing written`); return; }
|
if (dry) { done('play', `dry run: ${p.changes ? `${p.changes} change(s)` : 'nothing to change'}; read-only, nothing written`); return; }
|
||||||
if (!p.changes) { done('play', 'listing already up to date'); return; }
|
if (!p.changes) { done('play', 'listing already up to date'); return; }
|
||||||
if (process.stdin.isTTY && !(await confirm(ctx, `Apply these ${p.changes} change(s) to Google Play (one edit, committed)?`))) { warn('play', 'nothing written'); return; }
|
if (process.stdin.isTTY && !(await confirm(ctx, `Apply these ${p.changes} change(s) to Google Play (one edit, committed)?`))) { warn('play', 'nothing written'); return; }
|
||||||
const todo = p.listings.filter(l => l.action !== 'same').map(l => bodies.find(b => b.language === l.key)!);
|
// The edit compares again with what it holds (a Console save or another run since the plan): only differing details
|
||||||
await play.edit(async id => {
|
// and languages are PUT; nothing left to change = the edit is deleted, not committed. Commit only after every PUT worked.
|
||||||
if (p.details.action !== 'same') {
|
let sent = 0;
|
||||||
|
await play.edit(async (id, ctl) => {
|
||||||
|
const cur = await play.call<Record<string, string>>('GET', `${play.API}/edits/${id}/details`);
|
||||||
|
const now = (await play.call<{ listings?: PlayListing[] }>('GET', `${play.API}/edits/${id}/listings`)).listings ?? [];
|
||||||
|
const q = playPlan(cur, details, now, bodies, { only: a.has('only') });
|
||||||
|
const todo = q.listings.filter(l => l.action !== 'same').map(l => bodies.find(b => b.language === l.key)!);
|
||||||
|
sent = q.changes;
|
||||||
|
if (!q.changes) { ctl.unchanged(); return; }
|
||||||
|
if (q.details.action !== 'same') {
|
||||||
await play.call('PUT', `${play.API}/edits/${id}/details`, details);
|
await play.call('PUT', `${play.API}/edits/${id}/details`, details);
|
||||||
log('play', `details: ${p.details.changes.map(ch => ch.field).join(', ')}`);
|
log('play', `details: ${q.details.changes.map(ch => ch.field).join(', ')}`);
|
||||||
}
|
}
|
||||||
for (const [i, b] of todo.entries()) {
|
for (const [i, b] of todo.entries()) {
|
||||||
await play.call('PUT', `${play.API}/edits/${id}/listings/${b.language}`, b);
|
await play.call('PUT', `${play.API}/edits/${id}/listings/${b.language}`, b);
|
||||||
log('play', step(i + 1, todo.length, b.language!));
|
log('play', step(i + 1, todo.length, b.language!));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
done('play', 'listing done');
|
done('play', sent ? 'listing done' : 'listing already up to date (the edit was deleted, nothing committed)');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 |
|
| API | operations | GET | other | wrapped by a command | owner only |
|
||||||
|---|---:|---:|---:|---:|---:|
|
|---|---:|---:|---:|---:|---:|
|
||||||
| App Store Connect API 4.5.1 | 1303 | 826 | 477 | 196 | 166 |
|
| App Store Connect API 4.5.1 | 1303 | 826 | 477 | 197 | 166 |
|
||||||
| Google Play Android Developer API v3 (revision 20261008) | 145 | 45 | 100 | 32 | 49 |
|
| Google Play Android Developer API v3 (revision 20261008) | 145 | 45 | 100 | 32 | 49 |
|
||||||
| Google Play Developer Reporting API v1beta1 (revision 20261008) | 25 | 15 | 10 | 6 | 0 |
|
| Google Play Developer Reporting API v1beta1 (revision 20261008) | 25 | 15 | 10 | 6 | 0 |
|
||||||
|
|
||||||
|
|
@ -386,7 +386,7 @@ Specs: Apple [App Store Connect API 4.5.1](https://developer.apple.com/sample-co
|
||||||
| `appStoreVersions_deleteInstance` | DELETE | `/v1/appStoreVersions/{id}` | owner only (typed confirm) | |
|
| `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 | |
|
||||||
| `appStoreVersions_gameCenterAppVersion_getToOneRelationship` | GET | `/v1/appStoreVersions/{id}/relationships/gameCenterAppVersion` | read | |
|
| `appStoreVersions_gameCenterAppVersion_getToOneRelationship` | GET | `/v1/appStoreVersions/{id}/relationships/gameCenterAppVersion` | read | |
|
||||||
| `appStoreVersions_getInstance` | GET | `/v1/appStoreVersions/{id}` | read | |
|
| `appStoreVersions_getInstance` | GET | `/v1/appStoreVersions/{id}` | read | apple/listing |
|
||||||
| `appStoreVersions_routingAppCoverage_getToOneRelated` | GET | `/v1/appStoreVersions/{id}/routingAppCoverage` | read | |
|
| `appStoreVersions_routingAppCoverage_getToOneRelated` | GET | `/v1/appStoreVersions/{id}/routingAppCoverage` | read | |
|
||||||
| `appStoreVersions_routingAppCoverage_getToOneRelationship` | GET | `/v1/appStoreVersions/{id}/relationships/routingAppCoverage` | read | |
|
| `appStoreVersions_routingAppCoverage_getToOneRelationship` | GET | `/v1/appStoreVersions/{id}/relationships/routingAppCoverage` | read | |
|
||||||
| `appStoreVersions_updateInstance` | PATCH | `/v1/appStoreVersions/{id}` | write (dry by default) | apple/listing |
|
| `appStoreVersions_updateInstance` | PATCH | `/v1/appStoreVersions/{id}` | write (dry by default) | apple/listing |
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,9 @@ Tests: `tests/idempotency.test.ts` runs the write commands twice against statefu
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
Status: **ok** = converges, second run writes nothing (tested where marked T). **writes** = converges but sends the
|
Status: **ok** = converges, second run writes nothing (tested twice where marked T; the rows without T are covered
|
||||||
same values again (no duplicate; noted below). **owner** = a public or irreversible step that asks first.
|
by the shared helpers, see "Not run twice in the tests" below). **owner** = a public or irreversible step that asks
|
||||||
|
first. No write path sends the same values again on a second run.
|
||||||
|
|
||||||
| command | key | on re-run | status |
|
| command | key | on re-run | status |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
|
|
@ -48,9 +49,9 @@ same values again (no duplicate; noted below). **owner** = a public or irreversi
|
||||||
| `apple iap-review` | one review screenshot per product (MD5 + not FAILED) | kept when the bytes match, else deleted and uploaded | ok |
|
| `apple iap-review` | one review screenshot per product (MD5 + not FAILED) | kept when the bytes match, else deleted and uploaded | ok |
|
||||||
| `apple subscriptions` | group reference name; product id; locale; promo offer code; campaign name; custom code | groups and subscriptions: findOrCreate + journal; localizations / offers / codes: createOnce; prices compared per territory, only differences sent; a subscription found late is read live (prices, intro) | ok T (twice, lost answer) |
|
| `apple subscriptions` | group reference name; product id; locale; promo offer code; campaign name; custom code | groups and subscriptions: findOrCreate + journal; localizations / offers / codes: createOnce; prices compared per territory, only differences sent; a subscription found late is read live (prices, intro) | ok T (twice, lost answer) |
|
||||||
| `apple offer-codes` | campaign name per product; custom code; one-time batches by count | campaign: findOrCreate + journal (names not known unique: no blind retry); codes: 409 = exists | ok T |
|
| `apple offer-codes` | campaign name per product; custom code; one-time batches by count | campaign: findOrCreate + journal (names not known unique: no blind retry); codes: 409 = exists | ok T |
|
||||||
| `apple win-back` | offer id per subscription | only missing offers; 409 = exists | ok (owner: asks) |
|
| `apple win-back` | offer id per subscription | only missing offers; 409 = exists | ok T (owner: asks) |
|
||||||
| `apple promoted` | product per promoted purchase | plan from the store; order PATCH only when it differs | ok |
|
| `apple promoted` | product per promoted purchase | plan from the store; order PATCH only when it differs | ok T |
|
||||||
| `apple preorder` | territory | plan from the store | ok (owner) |
|
| `apple preorder` | territory | plan from the store; a territory already on pre-order with that date is left | ok T (owner) |
|
||||||
| `apple cpp create` | page name; locale | page: findOrCreate + journal; locales from a fresh read, 409 = exists | ok T |
|
| `apple cpp create` | page name; locale | page: findOrCreate + journal; locales from a fresh read, 409 = exists | ok T |
|
||||||
| `apple cpp upload` / `apple ppo upload` / `apple screenshots` | display type; position + MD5 | set: findOrCreate (unique, 409 = found); screenshots: matching prefix kept, rest replaced in order | ok T (twice, crash on the 3rd file) |
|
| `apple cpp upload` / `apple ppo upload` / `apple screenshots` | display type; position + MD5 | set: findOrCreate (unique, 409 = found); screenshots: matching prefix kept, rest replaced in order | ok T (twice, crash on the 3rd file) |
|
||||||
| `apple cpp submit` / `apple events submit` / `apple iap-submit` | the app's draft submission; version id per item | draft reused or created once (journal); an item in the draft is not added again | ok T (iap-submit) (owner: submit asks) |
|
| `apple cpp submit` / `apple events submit` / `apple iap-submit` | the app's draft submission; version id per item | draft reused or created once (journal); an item in the draft is not added again | ok T (iap-submit) (owner: submit asks) |
|
||||||
|
|
@ -59,7 +60,7 @@ same values again (no duplicate; noted below). **owner** = a public or irreversi
|
||||||
| `apple ppo create` | test name (open tests only); treatment name; locale | findOrCreate + journal for test and treatments | ok T |
|
| `apple ppo create` | test name (open tests only); treatment name; locale | findOrCreate + journal for test and treatments | ok T |
|
||||||
| `apple previews` | preview type; position + MD5; poster time code | like screenshots; poster PATCH only where it differs | ok |
|
| `apple previews` | preview type; position + MD5; poster time code | like screenshots; poster PATCH only where it differs | ok |
|
||||||
| `apple testflight groups` | group name | findOrCreate + journal, 409 = found | ok T |
|
| `apple testflight groups` | group name | findOrCreate + journal, 409 = found | ok T |
|
||||||
| `apple testflight testers` | email (masked) per group | only missing testers / memberships; 409 = exists | ok (owner: asks) |
|
| `apple testflight testers` | email (masked) per group | only missing testers / memberships; 409 = exists | ok T (owner: asks) |
|
||||||
| `apple testflight what-to-test` / `info` | locale; fields | POST missing locales, PATCH changed fields only | ok |
|
| `apple testflight what-to-test` / `info` | locale; fields | POST missing locales, PATCH changed fields only | ok |
|
||||||
| `apple testflight distribute` | group per build | relationship adds (same when sent twice); beta review once per build (409 = exists) | ok (owner) |
|
| `apple testflight distribute` | group per build | relationship adds (same when sent twice); beta review once per build (409 = exists) | ok (owner) |
|
||||||
| `apple testflight expire` | build | only unexpired builds planned | ok (owner) |
|
| `apple testflight expire` | build | only unexpired builds planned | ok (owner) |
|
||||||
|
|
@ -70,20 +71,20 @@ same values again (no duplicate; noted below). **owner** = a public or irreversi
|
||||||
| `apple adhoc profile` | profile name (+ dated names of earlier runs) | a current profile (also a dated one) ends the run; a new name never collides | ok |
|
| `apple adhoc profile` | profile name (+ dated names of earlier runs) | a current profile (also a dated one) ends the run; a new name never collides | ok |
|
||||||
| `apple signing ensure` | certificate with a local key (SPKI); profile with that certificate | a lost certificate answer keeps the pending key and finds the certificate by its public key (now or on the next run); profiles: createOnce, re-read | ok |
|
| `apple signing ensure` | certificate with a local key (SPKI); profile with that certificate | a lost certificate answer keeps the pending key and finds the certificate by its public key (now or on the next run); profiles: createOnce, re-read | ok |
|
||||||
| `apple upload` | build upload per version + build number | a COMPLETE upload is not sent again (only the wait); an unfinished one is resumed; reservations createOnce | ok |
|
| `apple upload` | build upload per version + build number | a COMPLETE upload is not sent again (only the wait); an unfinished one is resumed; reservations createOnce | ok |
|
||||||
| `apple listing` | version (editable); locale | see "open points" | writes |
|
| `apple listing` | version string (editable, iOS); locale; build per version | plan from the store; version: findOrCreate (fresh GET right before the create, journal, unique: a lost answer looks first); localizations: createOnce (409 / lost answer = found, then only differing fields PATCHed); unchanged localizations skipped; the build is not re-attached when it is attached | ok T (twice, changed field, lost answer, 409) |
|
||||||
| `apple appinfo` | categories, age rating, rights, price, availability | PATCHes every run (same values); price / availability only when missing | writes |
|
| `apple appinfo` | categories, age rating, rights, price, availability | each compared with the live value, only what differs is PATCHed; price schedule and availability only when missing (an existing price is never changed here: `prices import`) | ok T (twice, one changed answer) |
|
||||||
| `analytics setup` | the ONGOING request | exists = done; createOnce | ok |
|
| `analytics setup` | the ONGOING request | exists = done; createOnce | ok |
|
||||||
| `reviews send` | review id (local `sent:` mark) | Apple 409 (already answered) = noted as sent; Play `:reply` replaces | ok (owner) |
|
| `reviews send` | review id (local `sent:` mark) | Apple 409 (already answered) = noted as sent; Play `:reply` replaces | ok (owner) |
|
||||||
| `play products` | product id | PATCH `allowMissing` (create or update) only when it differs; activation only when not ACTIVE | ok T |
|
| `play products` | product id | PATCH `allowMissing` (create or update) only when it differs; activation only when not ACTIVE | ok T |
|
||||||
| `play subscriptions` | product id; base plan id; offer id | create: 409 = found (createOnce); PATCH only differences; activation only when needed | ok T (twice, lost answer) |
|
| `play subscriptions` | product id; base plan id; offer id | create: 409 = found (createOnce); PATCH only differences; activation only when needed | ok T (twice, lost answer) |
|
||||||
| `play images` | language + image type, sha256 in order | one read edit compares; only changed types are cleared and uploaded, in one edit per language | ok T |
|
| `play images` | language + image type, sha256 in order | one read edit compares; only changed types are cleared and uploaded, in one edit per language | ok T |
|
||||||
| `play listing` | language | see "open points" | writes |
|
| `play listing` | language; details | compared like the dry run (`playPlan`), again inside the write edit: only differing details / languages PUT; nothing differs = the edit is deleted, not committed; commit only after every PUT worked | ok T (twice, store current by the time the edit opens) |
|
||||||
| `play release` | versionCode; track release | a versionCode Play has is reused, not uploaded; an identical track release is not PUT; nothing changed = edit deleted | ok T |
|
| `play release` | versionCode; track release | a versionCode Play has is reused, not uploaded; an identical track release is not PUT; nothing changed = edit deleted | ok T |
|
||||||
| `play upload` | versionCode + track | already on that track with that status = done | ok |
|
| `play upload` | versionCode + track | already on that track with that status = done | ok T |
|
||||||
| `play rollout` | track releases | the same releases = edit deleted, not committed | ok T |
|
| `play rollout` | track releases | the same releases = edit deleted, not committed | ok T |
|
||||||
| `play data-safety` | the form | Play has no read API for it: the same CSV is sent again (a set, no duplicates) | writes |
|
| `play data-safety` | sha256 of package + CSV (`.storebound/data-safety.sha256`) | Play cannot read the form back: the hash of the last upload is kept locally, the same CSV is not sent again; `--force` sends it anyway (after a hand edit in Play Console) | ok T |
|
||||||
| `play share` | none (a new link each time) | a new internal sharing artifact per run (asks first; links expire in 60 days) | owner |
|
| `play share` | none (a new link each time) | a new internal sharing artifact per run (asks first; links expire in 60 days) | owner |
|
||||||
| `prices import` | product x store x region | diff first; only changed product / store pairs written (`--reconvert` always rewrites Play regions) | ok |
|
| `prices import` | product x store x region | diff first; only changed product / store pairs written (`--reconvert` always rewrites Play regions) | ok T (Play) |
|
||||||
| `revenuecat sync` | store identifier + app; lookup keys | plan from a fresh read; creates through createOnce (409 = found by key); attaches are the same twice | ok |
|
| `revenuecat sync` | store identifier + app; lookup keys | plan from a fresh read; creates through createOnce (409 = found by key); attaches are the same twice | ok |
|
||||||
| `ads apple bid / budget / pause` | campaign / keyword | PUT of a value | ok (owner) |
|
| `ads apple bid / budget / pause` | campaign / keyword | PUT of a value | ok (owner) |
|
||||||
| `web init` | file content | unchanged files are not written | ok |
|
| `web init` | file content | unchanged files are not written | ok |
|
||||||
|
|
@ -91,13 +92,19 @@ same values again (no duplicate; noted below). **owner** = a public or irreversi
|
||||||
| `console fill` | none | fills fields in a visible browser, never presses Save / Submit / Next | ok (never saves) |
|
| `console fill` | none | fills fields in a visible browser, never presses Save / Submit / Next | ok (never saves) |
|
||||||
| `storebound api <write>` | none (one raw request) | a POST without a clear answer is not retried; check with a GET first | raw |
|
| `storebound api <write>` | none (one raw request) | a POST without a clear answer is not retried; check with a GET first | raw |
|
||||||
|
|
||||||
## Open points (owned by another change)
|
## Not run twice in the tests
|
||||||
|
|
||||||
- `apple listing`: the version is matched by "the editable version", not by its version string, and a new one is
|
No row is open. These write paths are not run twice against the store doubles; they converge through the shared,
|
||||||
created without findOrCreate; localizations are POSTed without `createOnce` (a 409 stops the run), and the build is
|
tested helpers instead:
|
||||||
re-attached (PATCH) every run. Should use findOrCreate for the version and localizations, and skip the build PATCH
|
|
||||||
when it is attached already.
|
- `apple previews`: the asset-set logic of `apple screenshots` (`keptPrefix`, `syncAssets`), tested with a crash on
|
||||||
- `play listing`: every run opens an edit, PUTs details and every listing and commits, also when nothing changed. Should
|
the 3rd file. `apple iap-review` and `apple events upload` compare MD5 / size with what is delivered before sending.
|
||||||
compare like its dry run (`listingChanges`, `detailsChanges`) and call `ctl.unchanged()` when nothing differs.
|
- `apple signing ensure`, `apple upload`: reservations and certificates through `createOnce` and lookups by key
|
||||||
- `apple appinfo`: categories, age rating and content rights are PATCHed every run. Should compare with the current
|
(tested in `helpers`); `apple adhoc profile` stops at a current profile. The doubles have no certificate, profile
|
||||||
values first.
|
or build upload pipeline.
|
||||||
|
- `revenuecat sync`: `createOnce` with RevenueCat's 409 (`isConflict` tested); there is no RevenueCat double.
|
||||||
|
- `apple testflight what-to-test` / `info` / `distribute` / `expire`, `apple cpp upload` / `ppo upload` (the
|
||||||
|
screenshot path), `analytics setup`, `reviews send`, `ads apple`, `web init`, `flow run`: plan from the store (or
|
||||||
|
the file) first, the same helpers.
|
||||||
|
- `prices import` on the App Store side: the doubles have no manual price list per schedule; the Play side is tested,
|
||||||
|
and both share `diffPrices` / `sameSchedule`.
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ CLI: `storebound` (or `bunx storebound` in a project that has it, or `bun <toolc
|
||||||
2. **Play Data safety (API).** Fill `dataSafety` (types not listed = not collected; `shared` = third party that is not
|
2. **Play Data safety (API).** Fill `dataSafety` (types not listed = not collected; `shared` = third party that is not
|
||||||
your service provider, e.g. ad networks; analytics vendors acting as processors are "collected" only).
|
your service provider, e.g. ad networks; analytics vendors acting as processors are "collected" only).
|
||||||
`storebound play data-safety --dry --csv store/data-safety.csv` to review, then `storebound play data-safety`.
|
`storebound play data-safety --dry --csv store/data-safety.csv` to review, then `storebound play data-safety`.
|
||||||
|
Play cannot read the form back: storebound keeps the hash of the last upload in `.storebound/data-safety.sha256`
|
||||||
|
and skips an unchanged CSV. After a hand edit in Play Console, `--force` sends the config's answers again.
|
||||||
Then check the summary in Play Console > Policy and programs > App content > Data safety.
|
Then check the summary in Play Console > Policy and programs > App content > Data safety.
|
||||||
3. **Play App content (UI).** Policy and programs > App content, each card with `store/declarations.md`:
|
3. **Play App content (UI).** Policy and programs > App content, each card with `store/declarations.md`:
|
||||||
privacy policy, app access, ads, content rating (IARC questionnaire), target audience and content, news, COVID-19,
|
privacy policy, app access, ads, content rating (IARC questionnaire), target audience and content, news, COVID-19,
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,17 @@ const LISTS: Record<string, { type: string; one?: boolean }> = {
|
||||||
'inAppPurchases/versions': { type: 'inAppPurchaseVersions' },
|
'inAppPurchases/versions': { type: 'inAppPurchaseVersions' },
|
||||||
'subscriptions/versions': { type: 'subscriptionVersions' },
|
'subscriptions/versions': { type: 'subscriptionVersions' },
|
||||||
'subscriptionGroups/versions': { type: 'subscriptionGroupVersions' },
|
'subscriptionGroups/versions': { type: 'subscriptionGroupVersions' },
|
||||||
|
'appStoreVersions/build': { type: 'builds', one: true },
|
||||||
|
'apps/appInfos': { type: 'appInfos' },
|
||||||
|
'appInfos/appInfoLocalizations': { type: 'appInfoLocalizations' },
|
||||||
|
'appInfos/ageRatingDeclaration': { type: 'ageRatingDeclarations', one: true },
|
||||||
|
'apps/appPriceSchedule': { type: 'appPriceSchedules', one: true },
|
||||||
|
'apps/appPricePoints': { type: 'appPricePoints' },
|
||||||
|
'apps/appAvailabilityV2': { type: 'appAvailabilities', one: true },
|
||||||
|
'appAvailabilities/territoryAvailabilities': { type: 'territoryAvailabilities' },
|
||||||
|
'apps/promotedPurchases': { type: 'promotedPurchases' },
|
||||||
|
'subscriptions/winBackOffers': { type: 'winBackOffers' },
|
||||||
|
'betaGroups/betaTesters': { type: 'betaTesters' },
|
||||||
};
|
};
|
||||||
/** Stores refuse a second resource with the same key (409 ENTITY_ERROR ... already exists). */
|
/** Stores refuse a second resource with the same key (409 ENTITY_ERROR ... already exists). */
|
||||||
const UNIQUE: Record<string, (r: R) => string> = {
|
const UNIQUE: Record<string, (r: R) => string> = {
|
||||||
|
|
@ -76,6 +87,12 @@ const UNIQUE: Record<string, (r: R) => string> = {
|
||||||
reviewSubmissions: r => `${r.rels.app}|${r.attributes.state}`,
|
reviewSubmissions: r => `${r.rels.app}|${r.attributes.state}`,
|
||||||
appStoreVersionPhasedReleases: r => String(r.rels.appStoreVersion),
|
appStoreVersionPhasedReleases: r => String(r.rels.appStoreVersion),
|
||||||
bundleIds: r => String(r.attributes.identifier),
|
bundleIds: r => String(r.attributes.identifier),
|
||||||
|
appStoreVersions: r => `${r.rels.app}|${r.attributes.platform}|${r.attributes.versionString}`,
|
||||||
|
appInfoLocalizations: r => `${r.rels.appInfo}|${r.attributes.locale}`,
|
||||||
|
appStoreVersionLocalizations: r => `${r.rels.appStoreVersion}|${r.attributes.locale}`,
|
||||||
|
promotedPurchases: r => String(r.rels.inAppPurchaseV2 ?? r.rels.subscription),
|
||||||
|
winBackOffers: r => `${r.rels.subscription}|${r.attributes.offerId}`,
|
||||||
|
betaTesters: r => String(r.attributes.email).toLowerCase(),
|
||||||
};
|
};
|
||||||
const ASSETS = /Screenshots$|^appPreviews$|^appScreenshots$/;
|
const ASSETS = /Screenshots$|^appPreviews$|^appScreenshots$/;
|
||||||
/** Attributes a new resource of a type starts with. */
|
/** Attributes a new resource of a type starts with. */
|
||||||
|
|
@ -83,6 +100,7 @@ const DEFAULTS: Record<string, Record<string, unknown>> = {
|
||||||
inAppPurchases: { state: 'MISSING_METADATA' }, subscriptions: { state: 'MISSING_METADATA' }, reviewSubmissions: { state: 'READY_FOR_REVIEW' },
|
inAppPurchases: { state: 'MISSING_METADATA' }, subscriptions: { state: 'MISSING_METADATA' }, reviewSubmissions: { state: 'READY_FOR_REVIEW' },
|
||||||
appCustomProductPageVersions: { state: 'PREPARE_FOR_SUBMISSION' }, devices: { status: 'ENABLED', deviceClass: 'IPHONE' },
|
appCustomProductPageVersions: { state: 'PREPARE_FOR_SUBMISSION' }, devices: { status: 'ENABLED', deviceClass: 'IPHONE' },
|
||||||
appStoreVersionPhasedReleases: { phasedReleaseState: 'INACTIVE' }, appEvents: { eventState: 'DRAFT' }, appStoreVersionExperiments: { state: 'PREPARE_FOR_SUBMISSION' },
|
appStoreVersionPhasedReleases: { phasedReleaseState: 'INACTIVE' }, appEvents: { eventState: 'DRAFT' }, appStoreVersionExperiments: { state: 'PREPARE_FOR_SUBMISSION' },
|
||||||
|
appStoreVersions: { appVersionState: 'PREPARE_FOR_SUBMISSION' }, betaTesters: { state: 'NOT_INVITED' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const singular = (t: string): string => t.replace(/s$/, '');
|
const singular = (t: string): string => t.replace(/s$/, '');
|
||||||
|
|
@ -144,6 +162,8 @@ export class FakeAsc {
|
||||||
main.attributes.uploadOperations = [{ method: 'PUT', url: `${UPLOAD_HOST}${main.id}`, offset: 0, length: Number(d.attributes.fileSize ?? 0), requestHeaders: [{ name: 'Content-Type', value: 'image/png' }] }];
|
main.attributes.uploadOperations = [{ method: 'PUT', url: `${UPLOAD_HOST}${main.id}`, offset: 0, length: Number(d.attributes.fileSize ?? 0), requestHeaders: [{ name: 'Content-Type', value: 'image/png' }] }];
|
||||||
main.attributes.assetDeliveryState = { state: 'AWAITING_UPLOAD' };
|
main.attributes.assetDeliveryState = { state: 'AWAITING_UPLOAD' };
|
||||||
}
|
}
|
||||||
|
// a tester belongs to the app of its groups (GET /v1/betaTesters?filter[apps]=)
|
||||||
|
if (d.type === 'betaTesters') { const g = [main.rels.betaGroups].flat()[0]; const app = g ? this.res.get(String(g))?.rels.app : undefined; if (app) main.rels.app = app; }
|
||||||
const r = this.put(main);
|
const r = this.put(main);
|
||||||
if (this.lag[d.type]) r.hiddenReads = this.lag[d.type];
|
if (this.lag[d.type]) r.hiddenReads = this.lag[d.type];
|
||||||
for (const inc of body.included ?? []) {
|
for (const inc of body.included ?? []) {
|
||||||
|
|
@ -202,15 +222,28 @@ export class FakeAsc {
|
||||||
}
|
}
|
||||||
if (method === 'PATCH') {
|
if (method === 'PATCH') {
|
||||||
if (rel === 'relationships' && type && id) {
|
if (rel === 'relationships' && type && id) {
|
||||||
|
const data = (body as { data: { id: string } | { id: string }[] | null }).data;
|
||||||
|
if (data && !Array.isArray(data)) {
|
||||||
|
// a to-one relationship (the build of a version): the target points back at the patched resource
|
||||||
|
for (const r of this.children(id, this.res.get(data.id)?.type ?? '')) delete r.rels[singular(type)];
|
||||||
|
const t = this.res.get(data.id);
|
||||||
|
if (t) t.rels[singular(type)] = id;
|
||||||
|
return new Response(null, { status: 204 });
|
||||||
|
}
|
||||||
// order of a screenshot / preview set
|
// order of a screenshot / preview set
|
||||||
const ids = ((body as { data: { id: string }[] }).data ?? []).map(d => d.id);
|
const ids = ((data ?? []) as { id: string }[]).map(d => d.id);
|
||||||
const base = Math.min(...ids.map(i => this.res.get(i)?.order ?? 0));
|
const base = Math.min(...ids.map(i => this.res.get(i)?.order ?? 0));
|
||||||
ids.forEach((i, k) => { const r = this.res.get(i); if (r) r.order = base + k; });
|
ids.forEach((i, k) => { const r = this.res.get(i); if (r) r.order = base + k; });
|
||||||
return new Response(null, { status: 204 });
|
return new Response(null, { status: 204 });
|
||||||
}
|
}
|
||||||
const self = id ? this.res.get(id) : undefined;
|
let self = id ? this.res.get(id) : undefined;
|
||||||
|
// the age rating declaration is addressed by its app info's id
|
||||||
|
if (self && type && self.type !== type) self = this.children(self.id, type)[0];
|
||||||
if (!self) return json({ errors: [{ status: '404' }] }, 404);
|
if (!self) return json({ errors: [{ status: '404' }] }, 404);
|
||||||
const attrs = (body as { data: { attributes?: Record<string, unknown> } }).data.attributes ?? {};
|
const attrs = (body as { data: { attributes?: Record<string, unknown> } }).data.attributes ?? {};
|
||||||
|
for (const [k, v] of Object.entries((body as { data: { relationships?: Record<string, { data: { id: string } | null }> } }).data.relationships ?? {})) {
|
||||||
|
if (v.data) self.rels[k] = v.data.id; else delete self.rels[k];
|
||||||
|
}
|
||||||
// inline creates (subscription prices, introductory offers) become children of the patched resource
|
// inline creates (subscription prices, introductory offers) become children of the patched resource
|
||||||
for (const inc of (body as { included?: { type: string; attributes?: Record<string, unknown>; relationships?: Record<string, { data: { id: string } }> }[] }).included ?? [])
|
for (const inc of (body as { included?: { type: string; attributes?: Record<string, unknown>; relationships?: Record<string, { data: { id: string } }> }[] }).included ?? [])
|
||||||
this.put({ type: inc.type, id: `${inc.type.slice(0, 8)}-${this.next}`, attributes: { ...(inc.attributes ?? {}) },
|
this.put({ type: inc.type, id: `${inc.type.slice(0, 8)}-${this.next}`, attributes: { ...(inc.attributes ?? {}) },
|
||||||
|
|
@ -244,6 +277,8 @@ export class FakePlay {
|
||||||
subs = new Map<string, Record<string, unknown>>();
|
subs = new Map<string, Record<string, unknown>>();
|
||||||
offers = new Map<string, Record<string, unknown>>();
|
offers = new Map<string, Record<string, unknown>>();
|
||||||
next = 1;
|
next = 1;
|
||||||
|
/** every Data safety CSV that was posted */
|
||||||
|
dataSafety: string[] = [];
|
||||||
/** versionCode the next bundle upload reports */
|
/** versionCode the next bundle upload reports */
|
||||||
bundleCode = 42;
|
bundleCode = 42;
|
||||||
|
|
||||||
|
|
@ -352,7 +387,7 @@ export class FakePlay {
|
||||||
if (m[4]) o.state = 'ACTIVE';
|
if (m[4]) o.state = 'ACTIVE';
|
||||||
return json(o);
|
return json(o);
|
||||||
}
|
}
|
||||||
if (method === 'POST' && p === '/dataSafety') return json({});
|
if (method === 'POST' && p === '/dataSafety') { this.dataSafety.push(String((body as { safetyLabels?: string }).safetyLabels ?? '')); return json({}); }
|
||||||
return err(599, 'UNKNOWN', `fake play: ${method} ${p}`);
|
return err(599, 'UNKNOWN', `fake play: ${method} ${p}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,16 @@ import { run as playSubscriptions } from '../cli/play/subscriptions';
|
||||||
import { run as playImages } from '../cli/play/images';
|
import { run as playImages } from '../cli/play/images';
|
||||||
import { run as playRollout } from '../cli/play/rollout';
|
import { run as playRollout } from '../cli/play/rollout';
|
||||||
import { run as playRelease } from '../cli/play/release';
|
import { run as playRelease } from '../cli/play/release';
|
||||||
|
import { run as appleListing } from '../cli/apple/listing';
|
||||||
|
import { run as appleAppinfo } from '../cli/apple/appinfo';
|
||||||
|
import { run as applePromoted } from '../cli/apple/promoted';
|
||||||
|
import { run as appleWinBack } from '../cli/apple/win-back';
|
||||||
|
import { run as applePreorder } from '../cli/apple/preorder';
|
||||||
|
import { run as playListing } from '../cli/play/listing';
|
||||||
|
import { run as playDataSafety } from '../cli/play/data-safety';
|
||||||
|
import { run as playUpload } from '../cli/play/upload';
|
||||||
|
import { run as prices } from '../cli/prices';
|
||||||
|
import { makeAab } from './build-fixtures';
|
||||||
import { ascEnv, BASE, capture, playEnv, project, restore } from './helpers/store-mock';
|
import { ascEnv, BASE, capture, playEnv, project, restore } from './helpers/store-mock';
|
||||||
import { installStores, type Stores, uninstallStores, writes } from './helpers/fake-stores';
|
import { installStores, type Stores, uninstallStores, writes } from './helpers/fake-stores';
|
||||||
|
|
||||||
|
|
@ -219,6 +229,185 @@ describe('Google Play: a second run writes nothing', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const APPLE_MD = '# App Store\n\n## en-US · English\n\n### subtitle\n```\nNotes that sync\n```\n\n### keywords\n```\nnotes,lists\n```\n\n### description\n```\nNotes for everyone.\n```\n\n### promotionalText\n```\nNow with lists.\n```\n\n### whatsNew\n```\nFaster sync.\n```\n';
|
||||||
|
|
||||||
|
/** An app with a released 1.0.0, an editable app info and a processed build 9 of 1.1.0. */
|
||||||
|
function appleListingStore(): void {
|
||||||
|
s.asc.put({ type: 'appStoreVersions', id: 'ver-old', attributes: { versionString: '1.0.0', appVersionState: 'READY_FOR_SALE', platform: 'IOS' }, rels: { app: APP } });
|
||||||
|
s.asc.put({ type: 'appInfos', id: 'info-1', attributes: { state: 'PREPARE_FOR_SUBMISSION' }, rels: { app: APP } });
|
||||||
|
s.asc.put({ type: 'builds', id: 'b-9', attributes: { version: '9', processingState: 'VALID' }, rels: { app: APP } });
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('listing, appinfo, data safety and the owner commands: a second run writes nothing', () => {
|
||||||
|
test('apple listing: version created (re-checked first), build attached, localizations created once; then nothing', async () => {
|
||||||
|
appleListingStore();
|
||||||
|
const p = project(CONFIG, { 'store/appstore.md': APPLE_MD });
|
||||||
|
const r = await twice(() => appleListing(p.ctx(['--version', '1.1.0', '--build', '9'])));
|
||||||
|
expect(r.first).toEqual(['POST /v1/appStoreVersions', expect.stringMatching(/^PATCH \/v1\/appStoreVersions\/.+\/relationships\/build$/), 'POST /v1/appInfoLocalizations', 'POST /v1/appStoreVersionLocalizations']);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
expect([count('appStoreVersions'), count('appInfoLocalizations'), count('appStoreVersionLocalizations')]).toEqual([2, 1, 1]);
|
||||||
|
// a changed text: only that field of that localization is PATCHed, the build is not attached again
|
||||||
|
const q = project(CONFIG, { 'store/appstore.md': APPLE_MD.replace('Notes for everyone.', 'Notes for all.') });
|
||||||
|
const before = s.calls.length;
|
||||||
|
await capture(() => appleListing(q.ctx(['--version', '1.1.0', '--build', '9'])));
|
||||||
|
const w = writes(s.calls.slice(before));
|
||||||
|
expect(w.map(c => `${c.method} ${c.path.replace(/\/[^/]+$/, '/:id')}`)).toEqual(['PATCH /v1/appStoreVersionLocalizations/:id']);
|
||||||
|
expect(Object.keys((w[0]!.body as { data: { attributes: object } }).data.attributes)).toEqual(['description']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('apple listing: a lost answer on the version create is found by the re-check, not created twice', async () => {
|
||||||
|
appleListingStore();
|
||||||
|
const p = project(CONFIG, { 'store/appstore.md': APPLE_MD });
|
||||||
|
s.faults.push({ method: 'POST', match: /^\/v1\/appStoreVersions$/, when: 'after', status: 502 });
|
||||||
|
const r = await capture(() => appleListing(p.ctx(['--version', '1.1.0'])));
|
||||||
|
expect(r.exit).toBe(null);
|
||||||
|
expect(r.err).toContain('no clear answer');
|
||||||
|
expect(count('appStoreVersions')).toBe(2);
|
||||||
|
expect(s.calls.filter(c => c.method === 'POST' && c.path === '/v1/appStoreVersions')).toHaveLength(1);
|
||||||
|
expect(count('appStoreVersionLocalizations')).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('apple listing: a localization the list does not show yet answers 409; it is used and updated, not created twice', async () => {
|
||||||
|
appleListingStore();
|
||||||
|
s.asc.put({ type: 'appStoreVersions', id: 'ver-2', attributes: { versionString: '1.1.0', appVersionState: 'PREPARE_FOR_SUBMISSION', platform: 'IOS', copyright: `${new Date().getFullYear()} Example Notes`, releaseType: 'MANUAL' }, rels: { app: APP } });
|
||||||
|
s.asc.put({ type: 'appStoreVersionLocalizations', id: 'vloc-en', attributes: { locale: 'en-US', description: 'Old.' }, rels: { appStoreVersion: 'ver-2' }, hiddenReads: 1 } as never);
|
||||||
|
const p = project(CONFIG, { 'store/appstore.md': APPLE_MD });
|
||||||
|
const r = await capture(() => appleListing(p.ctx(['--version', '1.1.0'])));
|
||||||
|
expect(r.exit).toBe(null);
|
||||||
|
expect(r.out).toContain('already exists, using it');
|
||||||
|
expect(count('appStoreVersionLocalizations')).toBe(1);
|
||||||
|
expect(s.asc.res.get('vloc-en')!.attributes.description).toBe('Notes for everyone.');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('play listing: one committed edit with only what differs; the second run opens no write edit and commits nothing', async () => {
|
||||||
|
s.play.live.listings['de-DE'] = { language: 'de-DE', title: 'Notizen' };
|
||||||
|
const p = project(CONFIG, { 'store/listing.md': LISTING });
|
||||||
|
const r = await twice(() => playListing(p.ctx([])));
|
||||||
|
expect(r.first).toEqual(['PUT /androidpublisher/v3/applications/com.example.notes/edits/edit-2/details', 'PUT /androidpublisher/v3/applications/com.example.notes/edits/edit-2/listings/en-US',
|
||||||
|
'POST /androidpublisher/v3/applications/com.example.notes/edits/edit-2:commit']);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
expect(s.play.committed).toHaveLength(1);
|
||||||
|
expect(s.play.edits.size).toBe(0);
|
||||||
|
expect(s.play.live.listings['de-DE']).toEqual({ language: 'de-DE', title: 'Notizen' }); // a language not in the file is left alone
|
||||||
|
});
|
||||||
|
|
||||||
|
test('play listing: the store reached the wanted state between plan and edit: the edit is deleted, not committed', async () => {
|
||||||
|
const p = project(CONFIG, { 'store/listing.md': LISTING });
|
||||||
|
// the plan sees an empty listing; right after it (before the write edit opens) another run makes it current
|
||||||
|
const orig = s.play.handle.bind(s.play);
|
||||||
|
let planned = false;
|
||||||
|
s.play.handle = (method, url, body) => {
|
||||||
|
if (method === 'DELETE' && /\/edits\/edit-1$/.test(url) && !planned) {
|
||||||
|
planned = true;
|
||||||
|
s.play.live.details = { defaultLanguage: 'en-US', contactEmail: 'support@example.com', contactWebsite: 'https://example.com' };
|
||||||
|
s.play.live.listings['en-US'] = { language: 'en-US', title: 'Example Notes', shortDescription: 'Notes.', fullDescription: 'Notes for everyone.' };
|
||||||
|
}
|
||||||
|
return orig(method, url, body);
|
||||||
|
};
|
||||||
|
const r = await capture(() => playListing(p.ctx([])));
|
||||||
|
expect(r.out).toContain('nothing committed');
|
||||||
|
expect(s.play.committed).toEqual([]);
|
||||||
|
expect(writes(s.calls)).toEqual([]);
|
||||||
|
expect(s.play.edits.size).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('apple appinfo: categories, age rating, content rights, price and availability set once, then compared and left', async () => {
|
||||||
|
s.asc.put({ type: 'appInfos', id: 'info-1', attributes: { state: 'PREPARE_FOR_SUBMISSION' }, rels: { app: APP } });
|
||||||
|
s.asc.put({ type: 'ageRatingDeclarations', id: 'age-1', attributes: {}, rels: { appInfo: 'info-1' } });
|
||||||
|
s.asc.put({ type: 'appPricePoints', id: 'app-pp-free', attributes: { customerPrice: '0.0' }, rels: { app: APP, territory: 'USA' } });
|
||||||
|
const cfg: ShipConfig = { ...CONFIG, apple: { ...CONFIG.apple!, info: { categories: { primary: 'PRODUCTIVITY' }, contentRights: 'DOES_NOT_USE_THIRD_PARTY_CONTENT', ageRating: { advertising: true } } as never } };
|
||||||
|
const p = project(cfg);
|
||||||
|
const r = await twice(() => appleAppinfo(p.ctx([])));
|
||||||
|
expect(r.first).toEqual(['PATCH /v1/appInfos/info-1', 'PATCH /v1/ageRatingDeclarations/info-1', `PATCH /v1/apps/${APP}`, 'POST /v1/appPriceSchedules', 'POST /v2/appAvailabilities']);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
expect(s.asc.res.get('age-1')!.attributes.advertising).toBe(true);
|
||||||
|
// one answer changed in the config: only the age rating is PATCHed
|
||||||
|
const q = project({ ...cfg, apple: { ...cfg.apple!, info: { ...cfg.apple!.info!, ageRating: { advertising: true, contests: 'INFREQUENT_OR_MILD' } } as never } });
|
||||||
|
const before = s.calls.length;
|
||||||
|
await capture(() => appleAppinfo(q.ctx([])));
|
||||||
|
expect(writes(s.calls.slice(before)).map(c => `${c.method} ${c.path}`)).toEqual(['PATCH /v1/ageRatingDeclarations/info-1']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('play data-safety: the same CSV is not sent again (hash in .storebound/); a changed one or --force is', async () => {
|
||||||
|
const ds = { collectsData: true, encryptedInTransit: true, deletionRequest: false, data: { PSL_DEVICE_ID: { shared: false, collect: ['analytics'] } } };
|
||||||
|
const p = project({ ...CONFIG, dataSafety: ds as never });
|
||||||
|
const r = await twice(() => playDataSafety(p.ctx([])));
|
||||||
|
expect(r.first).toEqual(['POST /androidpublisher/v3/applications/com.example.notes/dataSafety']);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
expect(existsSync(join(p.root, '.storebound', 'data-safety.sha256'))).toBe(true);
|
||||||
|
let before = s.calls.length;
|
||||||
|
await capture(() => playDataSafety(p.ctx(['--force'])));
|
||||||
|
expect(writes(s.calls.slice(before))).toHaveLength(1);
|
||||||
|
const q = project({ ...CONFIG, dataSafety: { ...ds, data: { ...ds.data, PSL_EMAIL: { shared: false, collect: ['functionality'] } } } as never });
|
||||||
|
mkdirSync(join(q.root, '.storebound'), { recursive: true });
|
||||||
|
writeFileSync(join(q.root, '.storebound', 'data-safety.sha256'), readFileSync(join(p.root, '.storebound', 'data-safety.sha256')));
|
||||||
|
before = s.calls.length;
|
||||||
|
await capture(() => playDataSafety(q.ctx([])));
|
||||||
|
expect(writes(s.calls.slice(before))).toHaveLength(1);
|
||||||
|
expect(s.play.dataSafety).toHaveLength(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('apple promoted: created and ordered once', async () => {
|
||||||
|
s.asc.put({ type: 'inAppPurchases', id: 'iap-pro', attributes: { productId: 'com.example.notes.pro', state: 'APPROVED' }, rels: { app: APP } });
|
||||||
|
s.asc.put({ type: 'inAppPurchases', id: 'iap-tip', attributes: { productId: 'com.example.notes.tip', state: 'APPROVED' }, rels: { app: APP } });
|
||||||
|
const p = project({ ...CONFIG, apple: { ...CONFIG.apple!, promoted: { products: ['com.example.notes.tip', 'com.example.notes.pro'] } } });
|
||||||
|
const r = await twice(() => applePromoted(p.ctx(['--yes'])));
|
||||||
|
expect(r.first.filter(x => x === 'POST /v1/promotedPurchases')).toHaveLength(2);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
expect(count('promotedPurchases')).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('apple win-back: the missing offer is created once', async () => {
|
||||||
|
const g = s.asc.put({ type: 'subscriptionGroups', id: 'grp-1', attributes: { referenceName: 'Pro' }, rels: { app: APP } });
|
||||||
|
s.asc.put({ type: 'subscriptions', id: 'sub-1', attributes: { productId: 'com.example.notes.monthly', state: 'APPROVED' }, rels: { subscriptionGroup: g.id } });
|
||||||
|
const cfg: ShipConfig = { ...CONFIG, subscriptions: [{ name: 'Pro', listings: { en: { name: 'Pro' } }, subscriptions: [
|
||||||
|
{ id: 'com.example.notes.monthly', period: 'P1M', level: 1, usd: 4.99, listings: { en: { title: 'Monthly', description: 'Pro every month.' } },
|
||||||
|
winBack: [{ id: 'come-back', type: 'free', duration: 'P1M', paidMonths: 1, lapsedMonths: { min: 1, max: 6 }, start: '2099-01-01' }] },
|
||||||
|
] } as never] };
|
||||||
|
const p = project(cfg);
|
||||||
|
const r = await twice(() => appleWinBack(p.ctx(['--yes'])));
|
||||||
|
expect(r.first).toEqual(['POST /v1/winBackOffers']);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
expect(count('winBackOffers')).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('apple preorder enable: territories set once; the same date again changes nothing', async () => {
|
||||||
|
const av = s.asc.put({ type: 'appAvailabilities', id: 'avail-1', attributes: { availableInNewTerritories: true }, rels: { app: APP } });
|
||||||
|
for (const t of ['USA', 'DEU']) s.asc.put({ type: 'territoryAvailabilities', id: `ta-${t}`, attributes: { available: true, contentStatuses: ['CANNOT_SELL'] }, rels: { appAvailability: av.id, territory: t } });
|
||||||
|
const p = project(CONFIG);
|
||||||
|
const date = new Date(Date.now() + 30 * 86400_000).toISOString().slice(0, 10);
|
||||||
|
const r = await twice(() => applePreorder(p.ctx(['enable', '--release-date', date, '--yes'])));
|
||||||
|
expect(r.first).toEqual(['PATCH /v1/territoryAvailabilities/ta-USA', 'PATCH /v1/territoryAvailabilities/ta-DEU']);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('apple testflight testers: created in their groups once', async () => {
|
||||||
|
s.asc.put({ type: 'betaGroups', id: 'grp-friends', attributes: { name: 'Friends', isInternalGroup: false }, rels: { app: APP } });
|
||||||
|
const p = project(CONFIG, { '.storebound/testers.csv': 'email,first_name,groups\ntester1@example.com,Ex,Friends\ntester2@example.com,Am,Friends\n' });
|
||||||
|
const r = await twice(() => appleTestflight(p.ctx(['testers', '--yes'])));
|
||||||
|
expect(r.first).toEqual(['POST /v1/betaTesters', 'POST /v1/betaTesters']);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
expect(count('betaTesters')).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('play upload: uploaded once; the same versionCode on the same track is not sent again', async () => {
|
||||||
|
const p = project(CONFIG, { 'store/listing.md': LISTING, 'build/android/app.aab': makeAab('com.example.notes', 42) });
|
||||||
|
const r = await twice(() => playUpload(p.ctx(['--yes'])));
|
||||||
|
expect(r.first).toEqual(['POST /upload/androidpublisher/v3/applications/com.example.notes/edits/edit-2/bundles', 'PUT /androidpublisher/v3/applications/com.example.notes/edits/edit-2/tracks/internal',
|
||||||
|
'POST /androidpublisher/v3/applications/com.example.notes/edits/edit-2:commit']);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
expect(s.play.committed).toHaveLength(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('prices import (Play): changed regions written once, then the diff is empty', async () => {
|
||||||
|
const p = project({ ...CONFIG, products: [CONFIG.products![0]!] }, { 'store/prices.csv': 'product,store,region,currency,price\ncom.example.notes.pro,play,DE,EUR,3.49\n' });
|
||||||
|
await capture(() => playProducts(p.ctx([])));
|
||||||
|
const r = await twice(() => prices(p.ctx(['import', '--store', 'play', '--yes'])));
|
||||||
|
expect(r.first.some(x => x.startsWith('PATCH /androidpublisher/v3/applications/com.example.notes/onetimeproducts/'))).toBe(true);
|
||||||
|
expect(r.second).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('crash midway and unclear answers', () => {
|
describe('crash midway and unclear answers', () => {
|
||||||
test('screenshot set: an upload that dies on the 3rd file leaves a prefix; the re-run finishes it without duplicates, in order', async () => {
|
test('screenshot set: an upload that dies on the 3rd file leaves a prefix; the re-run finishes it without duplicates, in order', async () => {
|
||||||
const files: Record<string, Uint8Array> = {};
|
const files: Record<string, Uint8Array> = {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue