feat(printer): badge print queue, Pi worker, captive-portal setup, admin printing view
- migration 20261018170000: pgmq badge_print/badge_print_dlq, print_stations, token-gated printer RPCs (claim/complete/fail/heartbeat), admin RPCs, welcome_checkin enqueue; badge_print_tests.sql (101 assertions) - apps/printer: Python worker (Playwright render -> brother_ql via pyusb), comitup captive-portal (Wi-Fi + HTTPS endpoint + anon key + token), arm64 image build + idempotent Pi setup/install scripts, 77 pytest - apps/admin: Printing view, station management/DLQ, global printer status pill, Print button on Registrations, standalone print renderer entry (print.html -> dist-print) with bundled fonts - docs: printing.md + architecture/schema/rpcs/tests/admin-app updates, apps/printer/AGENT.md operating manual - e2e: printing.spec.ts Co-authored-by: Stephan Charles <[email protected]> Co-authored-by: Amelia Hernandez <[email protected]> Co-authored-by: Markus Franz <[email protected]> Co-authored-by: Sabrina Hota <[email protected]> Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
1 parent
0f3720d48a
commit
00c89c1b48
55 files changed
+7406
-29
No files matched your search
@@ -450,6 +450,48 @@ default per event. All three functions are `security definer` with an empty
|
||||
`search_path`, revoke execution from `PUBLIC` / `anon`, and grant it back only to
|
||||
`authenticated` (the admin check is enforced inside each function).
|
||||
|
||||
## Badge printing
|
||||
|
||||
Source: [20261018170000_badge_print_queue.sql](../../supabase/migrations/20261018170000_badge_print_queue.sql).
|
||||
The full contract — payload, state derivation, token security model, retry /
|
||||
dead-letter semantics — lives in
|
||||
[printing.md](./printing.md#4-rpcs); this is the function inventory.
|
||||
|
||||
**Admin RPCs** (`security definer`, empty `search_path`, `is_admin()` inside,
|
||||
granted to `authenticated` only):
|
||||
|
||||
- `enqueue_badge_print(p_registration_id)` → `bigint` — queue one attendee's
|
||||
badge for printing (`kind = reprint`); raises when the event has no usable
|
||||
layout.
|
||||
- `create_print_station(p_name)` → `(id, token)` — register a printer station;
|
||||
the `cvp_…` token is returned **once**, only its SHA-256 digest is stored.
|
||||
- `rename_print_station(p_id, p_name)` → `void` — rename a station (also
|
||||
revoked ones).
|
||||
- `revoke_print_station(p_id)` → `void` — retire a station; its token fails
|
||||
immediately.
|
||||
- `get_print_overview()` → `jsonb` — stations with a derived state, queue
|
||||
counters, the last 20 completed jobs and the dead letters.
|
||||
- `requeue_dead_badge_print(p_msg_id)` → `bigint` / `discard_dead_badge_print(p_msg_id)` → `void`
|
||||
— dead-letter triage.
|
||||
|
||||
**Printer RPCs** (granted to `anon` — the Pi has no user session; gated by the
|
||||
station token, invalid/revoked raises SQLSTATE `28000`):
|
||||
|
||||
- `printer_claim_badge_job(p_token, p_vt, p_wait_seconds)` →
|
||||
`(msg_id, read_ct, payload)` — long-poll claim; the wait is clamped to **2 s**
|
||||
because the `anon` role has a 3 s `statement_timeout`; a message read more
|
||||
than 3 times is dead-lettered instead of returned.
|
||||
- `printer_complete_badge_job(p_token, p_msg_id)` → `boolean` — archive the job.
|
||||
- `printer_fail_badge_job(p_token, p_msg_id, p_error, p_retryable)` → `text` —
|
||||
`retry` (backoff via `set_vt`) while attempts remain, else `dead_letter`.
|
||||
- `printer_heartbeat(p_token, p_status)` → `jsonb` — liveness + status beacon;
|
||||
returns the station's current `name` (the worker adopts renames from it).
|
||||
|
||||
**Changed existing RPC:** `welcome_checkin` re-creates with one addition — on a
|
||||
genuine **first** check-in it enqueues the badge job in the same transaction
|
||||
when the event has a layout with elements (see
|
||||
[welcome_checkin](#welcome_checkinp_attendee_qr--attendee_email-attendee_name-already).
|
||||
|
||||
## Error handling
|
||||
|
||||
RPCs raise Postgres exceptions with human-readable messages (e.g. `you cannot
|
||||
|
||||
Reference in new issue
Block a user