Add the list block and the module layer with the note module
Security / Vulnerability check (push) Successful in 41s
Test / Lint and test (push) Successful in 1m50s

The list block prints items with a dot, dash, number or checkbox bullet,
wrapping a long item with a hanging indent; a checkbox list ticks its
done items as [√], or [x] on code pages without √. It stands alone or
inside a box, and its items, bullet and done fields carry their enums
and limits as jsonschema tags.

internal/pkg/modules holds modules that build ordinary jobs from their
own payloads: a registry by name, an Env with the clock, time zone and
time layout, strict payload decoding that reports every problem, ErrSkip
and PayloadError. The note module prints a boxed note with an optional
checklist and a time stamp in the footer.

Three routes join the route table: POST /api/v1/print/{module} and
POST /api/v1/preview/{module}, which take ?copies and a reserved
?printer, and GET /api/v1/modules. Print and the module route share one
submit path, and preview shares one too. New error codes:
invalid_payload, invalid_query, unknown_printer, module_not_found and
module_failed; a module that builds an invalid receipt is logged and
reported to Sentry once. [format] gains timezone and time_layout, the
binary embeds the time zone database, and uberbringer preview takes
--module.

The note receipt passed on the TM-T88IV, and its bytes are pinned in
TestPaperReceipts. docs/api.md describes the list block, the module
routes and the note payload; docs/swagger.json is regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57_WolveandClaude Opus 5.5 committed 2026-11-30 10:55:50 -06:00
1 parent 6b2e402f1a
commit 3e9779f71a
69 files changed
+3092 -262

No files matched your search

+26 -7
View File
@@ -13,8 +13,11 @@ REST API and prints them on an EPSON ESC/POS network receipt printer.
character size, so words are never cut in half.
- **Rich elements**: bold, underline, inverse, sizes 1–8, two fonts,
alignment, QR codes, EAN/UPC/CODE39/CODE128 barcodes, images, raw ESC/POS.
- **Boxes, rules and key-value rows**: single or double CP437 borders with
titles, dividers and footers, sized to the paper when the job prints.
- **Boxes, rules, key-value rows and lists**: single or double CP437
borders with titles, dividers and footers, and bulleted, numbered or
checkbox lists, sized to the paper when the job prints.
- **Modules**: send a few plain fields, such as a note's title, text and
checklist, and get a laid-out receipt back.
- **Preview**: see the exact lines a job prints, without using paper.
- **Images that print well**: PNG, JPEG, GIF or WebP from a URL or base64,
scaled to the paper and dithered. Image URLs can't reach internal network
@@ -123,7 +126,7 @@ make run
## API
[docs/api.md](docs/api.md) is the API reference: the routes, the print
elements and blocks, and the error codes.
elements and blocks, the modules, and the error codes.
[docs/swagger.json](docs/swagger.json) is the OpenAPI 3.1 document,
generated from the route table; the daemon serves it at `GET /openapi.json`.
@@ -182,6 +185,14 @@ Settings worth knowing:
- `format.max_lines` (default `2000`): a job that would print more lines,
all copies counted, fails instead of printing. It is a backstop against
runaway text; `/api/v1/preview` answers such a job with `422`.
- `format.timezone` (default `Local`) and `format.time_layout` (default
`02 Jan 15:04`): how [modules](docs/api.md#modules) print times, such as
a note's stamp. The zone is an IANA name such as `Europe/London`, `UTC`,
or `Local` for the host's zone; the binary carries the zone database, so
names load on hosts and containers without one. The layout is Go's
notation, in which `02 Jan 2006 15:04:05` stands for the parts of a date,
e.g. `2006-01-02 15:04`. A layout that shows no part of a date is an
error.
- `webserver.trusted_proxies` / `proxy_header`: the real client IP for
per-client rate limits comes from the `X-Real-IP` header set by the reverse
proxy (Caddy, as `install.sh` configures it) on `127.0.0.1`.
@@ -201,9 +212,13 @@ Settings worth knowing:
and one Sentry event.
- A print job that fails after its retries is logged as ERROR `job failed`
with its `job_id`, and is reported to Sentry.
- A module that builds an invalid receipt (`422` `module_failed`) is
logged as ERROR `module built an invalid receipt`, with the `module` and
the number of `problems` but not the problems themselves, and is
reported to Sentry once.
- Refusals are never logged at ERROR and never go to Sentry. Refusals are
4xx answers, the `queue_full` and `shutting_down` 503s, and 503s from
`/healthz`.
4xx answers other than `module_failed`, the `queue_full` and
`shutting_down` 503s, and 503s from `/healthz`.
## Command line
@@ -212,6 +227,7 @@ uberbringer [--config config.toml] run the daemon (default command)
uberbringer secret print a new random API secret
uberbringer token [--subject s] [--ttl 720h] print a signed bearer token
uberbringer preview [file.json|-] show the lines a job would print
uberbringer preview --module note [file|-] show the receipt a module builds
uberbringer config get <key> print one setting, e.g. webserver.port
uberbringer version print the version
```
@@ -229,8 +245,10 @@ file.
argument, and lays it out for the printer in the config, as
`/api/v1/preview` does. It prints nothing and fetches no images. On a
terminal it shows bold, underlined and inverted text as such; warnings go
to standard error. It reads the same config as the daemon, so
`api.secret` and `printer.address` must be set even though neither is used.
to standard error. With `--module`, the input is that module's payload, as
`/api/v1/print/:module` takes it, built at the time now. It reads the same
config as the daemon, so `api.secret` and `printer.address` must be set even
though neither is used.
The daemon shuts down gracefully on SIGINT/SIGTERM. A receipt that is already
printing is finished, and jobs still waiting are marked failed.
@@ -295,6 +313,7 @@ internal/app/uberbringer/ CLI commands and wiring
internal/pkg/config/ Config from TOML and UBERBRINGER_* variables (Viper): defaults, validation
internal/pkg/escpos/ ESC/POS command builder, code pages, barcodes, QR, raster, status, interpreter
internal/pkg/receipt/ Job format, validation, text folding, word wrap, blocks, rendering, preview
internal/pkg/modules/ Modules that build jobs from plain payloads, such as note; strict payload decoding
internal/pkg/raster/ Image decoding, scaling and dithering
internal/pkg/safehttp/ SSRF-guarded image fetching
internal/pkg/printer/ TCP printer client (port 9100) and status queries