// Checks a console form against the config after the agent (or the owner) filled it. Read-only. // storebound console verify
[--from-text ] [--json] // apple-app-privacy: the page text of the App Privacy page (the Data Types section's per-type summaries; the App Store // Connect API has no App Privacy endpoint). play-app-record: the JSON of the plan's capture snippet (input states) or // the page text. play-content-rating, play-target-audience: the summary page text. apple-app-record: the App Store // Connect API (the app by bundle id; a GET) or, with --from-text, the page text. apple-age-rating: the API. // Exit 1 on any mismatch, and when nothing could be matched. Pure logic in cli/lib/console-verify.ts. MCP: console_verify. import { readFileSync } from 'node:fs'; import type { Ctx } from '../lib/ctx'; import { FORM_IDS, isForm } from '../lib/console-answers'; import { verifyAgeRatingApi, verifyAppRecordApi, type VerifyResult, verifyTable, verifyText } from '../lib/console-verify'; import { printJson } from '../lib/log'; async function readText(src: string): Promise { if (src === '-' || src === 'true') return Bun.stdin.text(); return readFileSync(src, 'utf8'); } export async function run(ctx: Ctx): Promise { const { config, root } = ctx.loaded; const args = ctx.args, json = args.has('json'); const form = args._[0]; if (!isForm(form)) throw new Error(`console verify [--from-text ]: one of ${FORM_IDS.join(', ')}`); const from = args.get('from-text'), inline = args.get('text'); let r: VerifyResult; if (from !== undefined || inline !== undefined) { const text = inline ?? await readText(from!); if (!text.trim()) throw new Error('console verify: the page text is empty'); r = verifyText(form, config, text); } else if (form === 'apple-app-record' || form === 'apple-age-rating') { const bundleId = config.apple?.bundleId; if (!bundleId) throw new Error('console verify: apple.bundleId is not set'); const { ascClient } = await import('../apple/asc'); const c = await ascClient(root, bundleId, config.apple?.appId); if (form === 'apple-app-record') { const found = await c.asc('GET', `/v1/apps?filter[bundleId]=${encodeURIComponent(bundleId)}`); const hit = (found.data as { attributes: { bundleId: string; name?: string; sku?: string; primaryLocale?: string } }[]).find(a => a.attributes.bundleId === bundleId); r = verifyAppRecordApi(config, hit?.attributes ?? null); } else { const info = await c.editableAppInfo(); const age = await c.maybe(`/v1/appInfos/${info.id}/ageRatingDeclaration`); r = verifyAgeRatingApi(config, (age?.data?.attributes ?? null) as Record | null); } } else throw new Error(`console verify ${form}: pass the page text with --from-text (run \`storebound console plan ${form}\` for what to capture)`); if (json) printJson(r); else console.log(verifyTable(r)); if (!r.ok) process.exitCode = 1; }