apps / health / catalog / validate: fixes from a read-only run against live store accounts

- API error bodies on one line (errorBody): Google and App Store Connect pretty-print errors, which hid
  SERVICE_DISABLED from the Play account check (reported permission instead of api-disabled), broke tables
  and turned serve's apps.list error into a JSON fragment
- apps list: failure says the reason and the fix (same words as apps check)
- newest App Store version by createdDate, iOS first (the API groups versions by platform); all versions
  read so no platform is missed; per-app reads four at a time
- apps check (apple): team app count from meta.paging.total with a one-app read
- Play Money without units (prices under 1.00) read as 0.xx, not NaN (catalog diff, subscription diffs)
- health: App Store Connect 404 for perfPowerMetrics / diagnosticSignatures means no field data yet;
  Play vitals behind a disabled Reporting API say so with the fix
- validate: gracRatingClassificationNumber optional, socialMediaAgeRestricted only when socialMedia is yes,
  socialMedia unanswered is a warning
- tests with sanitized recorded responses (tests/store-real-shapes.test.ts)
This commit is contained in:
CRTkafa 2026-10-10 20:50:26 +00:00
parent 8bb28db45c
commit b8da75e519
14 changed files with 342 additions and 34 deletions

View file

@ -11,3 +11,15 @@ export async function checkUrl(url: string, o: { body?: boolean; timeoutMs?: num
return { url, status: null, error: (e as Error).message };
}
}
/**
* An API error body for an Error message: JSON on one line (App Store Connect and Google pretty-print their errors,
* which broke tables, `lastLine` in serve and matching on the error reason), an HTML page named as such, else the text
* with its whitespace collapsed. At most `max` characters.
*/
export function errorBody(text: string, max = 1500): string {
if (/^\s*</.test(text)) return '(HTML error page)';
let s: string;
try { s = JSON.stringify(JSON.parse(text)); } catch { s = text.replace(/\s+/g, ' ').trim(); }
return s.length > max ? s.slice(0, max) + '…' : s;
}