Pathbuilder import, backend: the sheet PDF and the build JSON (#958) #1361
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/958-pathbuilder-import-backend"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Backend half of Pathbuilder import (#958, IS-429, D82). The page that uses it follows in a separate PR.
Routes (GM, or the player of the character's page; the campaign must play Pathfinder 2e):
POST /api/campaigns/{cid}/lore/{entry_id}/sheet/import/pathbuilder: body{"json": <build or its text>, "code": "484225"?}(1 MB cap).POST .../sheet/import/pathbuilder/pdf: multipartfile(a.pdf, 10 MB cap, judged on Content-Length and as it streams, before it is held); optional?code=.commit= preview, nothing saved;?commit=1&expected_version=Nsaves;&replace=1confirms replacing a sheet that is not from this character. Answer:{mode: create|update|replace, committed, source_ref, sheet_id, version, needs_confirmation, data, values, changes, report: {read, not_read, warnings, entries, checks, counts}, sheet?}. Documented in docs/API.md.Design
imports.pathbuilderinapp/sheets/builtin/pf2e/character.json(D82, "through the pack's maps"); a test holds every path it names to the definition. Pure readers inapp/sheets/importers/.source_ref(kind pathbuilder, id if both have one, else name) matches; rows an import made are replaced, hand-added rows stay; a sheet from elsewhere needsreplace=1and its earlier state stays in the version history (importkind).checkshold Pathbuilder's own numbers against what Quest Board works out (a difference is a warning).connect-src 'self'inwebapp/frontend/nginx.confblockshttps://pathbuilder2e.com; the browser fetch needs that origin added.Security
_locked_by) are checked before any row is removed or written; a locked list's rows are untouched and listed in the report; a GM is never locked out.Tests: tests/sheets/test_pathbuilder_import.py (47): full mapping of the sample JSON and PDF fields, a synthetic AcroForm PDF end to end, garbage/oversize/non-PDF/encrypted/not-the-sheet, permissions, preview saves nothing, confirm saves, re-import updates, replace, locks (sheet and definition level), gate and timeout.
No migration; no bot API change.
🤖 Generated with Claude Code
Preview then confirm routes under /lore/{entry_id}/sheet/import/pathbuilder (JSON) and .../pdf; the mapping is the pf2e definition's imports.pathbuilder map; app/sheets/importers/ reads (pure), app/services/sheet_import.py matches names to the campaign's rules, honours GM locks and saves or updates by source_ref provenance. PDF reads are bounded (own executor, 503 when full, spooled upload with a size cap). The server never fetches pathbuilder2e.com. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>