Skip to content

Templates: redesign to the v1 API contract + visual layout support - #596

Merged
marcvergees merged 7 commits into
fireform-core:development-approach-cfrom
chetanr25:template_registry
Aug 13, 2026
Merged

Templates: redesign to the v1 API contract + visual layout support#596
marcvergees merged 7 commits into
fireform-core:development-approach-cfrom
chetanr25:template_registry

Conversation

@chetanr25

@chetanr25 chetanr25 commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Templates: redesign to the v1 API contract + visual layout support

Implements the whole templates layer from the contract: a registry keyed by form_type holding field definitions, where each value comes from, and where each field sits on the page. Form generation and extraction validation both read this shape.

Closes #549. Also covers the field catalog and PDF flow from #609.

What this adds

  • All 8 template endpoints from the contract.
  • Every field declares a source, which decides what else it needs:
    • schema needs an incident mapping
    • static needs the text to print
    • manual needs neither, a person types it per incident
    • open needs a description, which is the instruction the model gets
  • Fields carry a layout box in PDF points, so the visual editor and the backend agree on coordinates.
  • GET /schema/fields returns every field in the incident contract with its path, type, aliases and PII flag. Built from the contract file itself, so it never drifts.
  • Uploading a PDF returns page geometry straight away and runs field detection in the background. Each detected box comes back as an editable field with its position filled in and ranked mapping suggestions.
  • A confident suggestion is applied for you. A weak one is only listed. A bad one is not shown at all, because a pre-filled mapping gets trusted more than it deserves.
  • Detection failing is not fatal. The PDF and its geometry are still stored, the draft says what went wrong, and the editor falls back to drawing boxes by hand.

Endpoints

Method Path What it does
GET /templates list registered templates
POST /templates register one, 409 on duplicate form type
GET /templates/{id} full template
PUT /templates/{id} replace a template
GET /templates/{id}/fields fields only, with required_only
POST /templates/pdf store a PDF, return page sizes, queue detection
GET /templates/pdf/{upload_id} poll the detection draft
GET /templates/{id}/pdf download a template's source PDF
GET /schema/fields search the incident contract field catalog

Fix: #549
Part of: #541

@chetanr25
chetanr25 force-pushed the template_registry branch 3 times, most recently from 0d0ef6f to f188299 Compare June 27, 2026 19:35
@chetanr25
chetanr25 changed the base branch from development to development-approach-c August 11, 2026 18:12
@chetanr25
chetanr25 marked this pull request as ready for review August 11, 2026 18:14
@chetanr25 chetanr25 changed the title [WIP] - Templates: redesign to the v1 API contract + visual layout support Templates: redesign to the v1 API contract + visual layout support Aug 12, 2026
…type. Also drops leftover scratch files, a duplicated size guard, and an unused fixture.
@marcvergees
marcvergees merged commit 849c219 into fireform-core:development-approach-c Aug 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Templates CRUD - API Contracts

2 participants