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

+546 -5
View File
@@ -3,7 +3,7 @@
"schemas": {
"Element": {
"additionalProperties": false,
"description": "Element is one item on a receipt. Its type selects which fields apply. On the blocks (box, rule and kv) and inside a box, a field that does not apply is an error; on the other types it is ignored, except for the block fields. width and height mean character multipliers for text, module width and bar height for barcodes, and target width in dots for images. A block's width is set by columns, in characters of its own size and font, never by width; without columns a block spans the line. The enums list the canonical spellings: apart from type and leader, other letter case is accepted too, and so are a few aliases such as centre and ean-13.",
"description": "Element is one item on a receipt. Its type selects which fields apply. On the blocks (box, rule, kv and list) and inside a box, a field that does not apply is an error; on the other types it is ignored, except for the block fields. width and height mean character multipliers for text, module width and bar height for barcodes, and target width in dots for images. A block's width is set by columns, in characters of its own size and font, never by width; without columns a block spans the line. The enums list the canonical spellings: apart from type and leader, other letter case is accepted too, and so are a few aliases such as centre and ean-13.",
"properties": {
"align": {
"description": "align places text, a QR code, a barcode or an image, a box's text, or a rule's label. Default left, center for a rule's label.",
@@ -22,8 +22,18 @@
"description": "bold prints the text in bold: a box's text, a rule's label.",
"type": "boolean"
},
"bullet": {
"description": "bullet marks each item of a list: dot, the default, dash, number (right-aligned to the widest number) or checkbox.",
"enum": [
"dot",
"dash",
"number",
"checkbox"
],
"type": "string"
},
"children": {
"description": "children are a box's body as elements, one level deep: text, feed, rule and kv. Set text or children, not both.",
"description": "children are a box's body as elements, one level deep: text, feed, rule, kv and list. Set text or children, not both.",
"items": {
"$ref": "#/components/schemas/Element"
},
@@ -49,6 +59,16 @@
"description": "data is a QR code's data, up to 7089 bytes of UTF-8, or a barcode's: digits for EAN and UPC, A-Z 0-9 -.$/+% and space for CODE39, printable ASCII for CODE128.",
"type": "string"
},
"done": {
"description": "done are the indexes into items, from 0, of a checkbox list's ticked items, each once. They print as [√], or [x] on code pages without √.",
"items": {
"maximum": 199,
"minimum": 0,
"type": "integer"
},
"type": "array",
"uniqueItems": true
},
"fit": {
"description": "fit shrinks a box to its widest line, title and footer included, and centres it. columns is then the most it may take.",
"type": "boolean"
@@ -89,6 +109,16 @@
"description": "invert prints white on black.",
"type": "boolean"
},
"items": {
"description": "items are a list's items, 1-200, none empty; required for list. An item too long for its line wraps with a hanging indent.",
"items": {
"minLength": 1,
"type": "string"
},
"maxItems": 200,
"minItems": 1,
"type": "array"
},
"leader": {
"description": "leader is the fill between a kv row's key and value: \".\", the default, \"·\", \" \" (or \"space\"), \"_\", \"-\" or \"─\".",
"enum": [
@@ -187,7 +217,7 @@
"type": "string"
},
"type": {
"description": "type is the kind of element. box, rule and kv are blocks, laid out to the printer model's width when the job prints.",
"description": "type is the kind of element. box, rule, kv and list are blocks, laid out to the printer model's width when the job prints.",
"enum": [
"text",
"feed",
@@ -198,7 +228,8 @@
"cut",
"box",
"rule",
"kv"
"kv",
"list"
],
"type": "string"
},
@@ -235,7 +266,7 @@
"type": "string"
},
"details": {
"description": "details lists every problem when an invalid_job fails validation, each naming the element by its path, e.g. elements[0].children[3] (qr).",
"description": "details lists every problem when a job fails validation (invalid_job), a module payload is invalid (invalid_payload) or a module builds an invalid receipt (module_failed). A job problem names the element by its path, e.g. elements[0].children[3] (qr); a payload problem names the field, e.g. done[0].",
"items": {
"type": "string"
},
@@ -390,6 +421,35 @@
],
"type": "object"
},
"ModuleInfo": {
"description": "ModuleInfo describes one module.",
"properties": {
"description": {
"description": "description says in one line what the module prints.",
"type": "string"
},
"name": {
"description": "name is the module's name in the module routes' paths, e.g. note.",
"type": "string"
}
},
"required": [
"name",
"description"
],
"type": "object"
},
"ModuleList": {
"description": "ModuleList is the body of GET /api/v1/modules: every module, sorted by name.",
"items": {
"$ref": "#/components/schemas/ModuleInfo"
},
"type": "array"
},
"ModulePayload": {
"description": "ModulePayload is a module's payload: a JSON object whose fields the module defines, such as a note's title, text and items.",
"type": "object"
},
"OpenAPIDocument": {
"description": "OpenAPIDocument is the body of GET /openapi.json: this API's OpenAPI 3.1 document, generated from the route table.",
"properties": {
@@ -788,6 +848,89 @@
]
}
},
"/api/v1/modules": {
"get": {
"description": "Every module the module routes take, sorted by name.",
"operationId": "listModules",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModuleList"
}
}
},
"description": "The modules"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Unauthorized. unauthorized: missing or invalid bearer token.",
"headers": {
"WWW-Authenticate": {
"description": "The challenge: Bearer realm=\"uberbringer\", with error=\"invalid_token\" when a token was sent but is not valid.",
"schema": {
"type": "string"
}
}
},
"x-uberbringer-codes": [
"unauthorized"
]
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Too Many Requests. rate_limited: too many requests, try again later.",
"headers": {
"Retry-After": {
"description": "How many seconds to wait before the client's next request is let through.",
"schema": {
"minimum": 1,
"type": "integer"
}
}
},
"x-uberbringer-codes": [
"rate_limited"
]
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Internal Server Error. internal_error: internal server error.",
"x-uberbringer-codes": [
"internal_error"
]
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "List the modules",
"tags": [
"modules"
]
}
},
"/api/v1/preview": {
"post": {
"description": "Validates the job as /api/v1/print does, renders it and reads the lines back from the rendered bytes. It prints nothing and fetches no images. The answer is JSON with the lines' styles when the Accept header prefers application/json to text/plain (for example application/json or application/*), and plain text otherwise.",
@@ -925,6 +1068,191 @@
]
}
},
"/api/v1/preview/{module}": {
"post": {
"description": "Builds the receipt as /api/v1/print/{module} does and answers as /api/v1/preview does: JSON with the lines' styles when the Accept header prefers application/json to text/plain, and plain text otherwise. It prints nothing and fetches no images.",
"operationId": "previewModule",
"parameters": [
{
"description": "The module's name, e.g. note. GET /api/v1/modules lists them.",
"in": "path",
"name": "module",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "How many copies to print, each cut separately: a whole number, 1-5. Default 1.",
"in": "query",
"name": "copies",
"required": false,
"schema": {
"type": "string"
}
},
{
"description": "Reserved for a second printer: only default is accepted. Any other query parameter is refused.",
"in": "query",
"name": "printer",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModulePayload"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PreviewResponse"
}
},
"text/plain; charset=utf-8": {
"schema": {
"type": "string"
}
}
},
"description": "The lines the printer would print"
},
"204": {
"description": "The module had nothing to print"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request. invalid_payload: invalid payload; invalid_query: invalid query parameter; unknown_printer: unknown printer.",
"x-uberbringer-codes": [
"invalid_payload",
"invalid_query",
"unknown_printer"
]
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Unauthorized. unauthorized: missing or invalid bearer token.",
"headers": {
"WWW-Authenticate": {
"description": "The challenge: Bearer realm=\"uberbringer\", with error=\"invalid_token\" when a token was sent but is not valid.",
"schema": {
"type": "string"
}
}
},
"x-uberbringer-codes": [
"unauthorized"
]
},
"404": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Not Found. module_not_found: module not found.",
"x-uberbringer-codes": [
"module_not_found"
]
},
"413": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Request Entity Too Large. body_too_large: request body is too large.",
"x-uberbringer-codes": [
"body_too_large"
]
},
"422": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Unprocessable Entity. module_failed: module built an invalid receipt; too_many_lines: receipt would print too many lines.",
"x-uberbringer-codes": [
"module_failed",
"too_many_lines"
]
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Too Many Requests. rate_limited: too many requests, try again later.",
"headers": {
"Retry-After": {
"description": "How many seconds to wait before the client's next request is let through.",
"schema": {
"minimum": 1,
"type": "integer"
}
}
},
"x-uberbringer-codes": [
"rate_limited"
]
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Internal Server Error. internal_error: internal server error.",
"x-uberbringer-codes": [
"internal_error"
]
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Show the lines a module's receipt prints, without printing it",
"tags": [
"modules"
]
}
},
"/api/v1/print": {
"post": {
"description": "Validates the whole job and queues it. The worker renders it in full before anything is sent to the printer, and fetches its images then, so a broken image URL shows up as a failed job.",
@@ -1075,6 +1403,216 @@
]
}
},
"/api/v1/print/{module}": {
"post": {
"description": "The module named in the path builds a receipt from the body, its own payload, which is decoded strictly: an unknown field or one of the wrong type is refused, with every problem listed. The receipt is then validated and queued as on /api/v1/print. A module with nothing to print answers 204.",
"operationId": "printModule",
"parameters": [
{
"description": "The module's name, e.g. note. GET /api/v1/modules lists them.",
"in": "path",
"name": "module",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "How many copies to print, each cut separately: a whole number, 1-5. Default 1.",
"in": "query",
"name": "copies",
"required": false,
"schema": {
"type": "string"
}
},
{
"description": "Reserved for a second printer: only default is accepted. Any other query parameter is refused.",
"in": "query",
"name": "printer",
"required": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModulePayload"
}
}
},
"required": true
},
"responses": {
"202": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/JobStatus"
}
}
},
"description": "The receipt is queued",
"headers": {
"Location": {
"description": "The job's URL, which answers with its status.",
"schema": {
"type": "string"
}
}
}
},
"204": {
"description": "The module had nothing to print"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Bad Request. invalid_payload: invalid payload; invalid_query: invalid query parameter; unknown_printer: unknown printer.",
"x-uberbringer-codes": [
"invalid_payload",
"invalid_query",
"unknown_printer"
]
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Unauthorized. unauthorized: missing or invalid bearer token.",
"headers": {
"WWW-Authenticate": {
"description": "The challenge: Bearer realm=\"uberbringer\", with error=\"invalid_token\" when a token was sent but is not valid.",
"schema": {
"type": "string"
}
}
},
"x-uberbringer-codes": [
"unauthorized"
]
},
"404": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Not Found. module_not_found: module not found.",
"x-uberbringer-codes": [
"module_not_found"
]
},
"413": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Request Entity Too Large. body_too_large: request body is too large.",
"x-uberbringer-codes": [
"body_too_large"
]
},
"422": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Unprocessable Entity. module_failed: module built an invalid receipt.",
"x-uberbringer-codes": [
"module_failed"
]
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Too Many Requests. rate_limited: too many requests, try again later.",
"headers": {
"Retry-After": {
"description": "How many seconds to wait before the client's next request is let through.",
"schema": {
"minimum": 1,
"type": "integer"
}
}
},
"x-uberbringer-codes": [
"rate_limited"
]
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Internal Server Error. internal_error: internal server error.",
"x-uberbringer-codes": [
"internal_error"
]
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
},
"description": "Service Unavailable. queue_full: print queue is full, try again shortly; shutting_down: server is shutting down.",
"headers": {
"Retry-After": {
"description": "Sent with queue_full: how many seconds to wait before trying again.",
"schema": {
"minimum": 1,
"type": "integer"
}
}
},
"x-uberbringer-codes": [
"queue_full",
"shutting_down"
]
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Queue the receipt a module builds from its payload",
"tags": [
"modules"
]
}
},
"/healthz": {
"get": {
"description": "Reads the printer's real-time status. A printer that looks not ready is read again 750 ms later, and only a problem that is still there gives 503. A printer that does not answer status requests is reported as status unknown with 200.",
@@ -1200,6 +1738,9 @@
{
"name": "meta"
},
{
"name": "modules"
},
{
"name": "print"
}