This commit is contained in:
seb
2026-09-26 23:06:09 +02:00
parent cbb2fdeb6d
commit 69f27a2942
19 changed files with 2231 additions and 0 deletions

View File

@@ -120,11 +120,19 @@ Generated from `@openapi` annotations in [`src/api/routes/`](../../src/api/route
| [`routes/posterminal/setOnAll.md`](routes/posterminal/setOnAll.md) | `PUT /posterminal/{id}/all` |
| [`routes/posterminal/setOff.md`](routes/posterminal/setOff.md) | `DELETE /posterminal/{id}/category/{categoryId}` |
| [`routes/posterminal/setOn.md`](routes/posterminal/setOn.md) | `PUT /posterminal/{id}/category/{categoryId}` |
| [`routes/printer/list.md`](routes/printer/list.md) | `GET /printer` |
| [`routes/printer/create.md`](routes/printer/create.md) | `POST /printer` |
| [`routes/printer/order.md`](routes/printer/order.md) | `PUT /printer/order` |
| [`routes/printer/delete.md`](routes/printer/delete.md) | `DELETE /printer/{id}` |
| [`routes/printer/get.md`](routes/printer/get.md) | `GET /printer/{id}` |
| [`routes/printer/update.md`](routes/printer/update.md) | `PATCH /printer/{id}` |
| [`routes/printer/:id.put.md`](routes/printer/:id.put.md) | `PUT /printer/{id}` |
| [`routes/quote/list.md`](routes/quote/list.md) | `GET /quote` |
| [`routes/quote/create.md`](routes/quote/create.md) | `POST /quote` |
| [`routes/quote/delete.md`](routes/quote/delete.md) | `DELETE /quote/{id}` |
| [`routes/quote/get.md`](routes/quote/get.md) | `GET /quote/{id}` |
| [`routes/quote/update.md`](routes/quote/update.md) | `PATCH /quote/{id}` |
| [`routes/stock/adjust.md`](routes/stock/adjust.md) | `POST /stock/adjust` |
| [`routes/supplier/list.md`](routes/supplier/list.md) | `GET /supplier` |
| [`routes/supplier/create.md`](routes/supplier/create.md) | `POST /supplier` |
| [`routes/supplier/delete.md`](routes/supplier/delete.md) | `DELETE /supplier/{id}` |

View File

@@ -80,9 +80,17 @@
"name": "Posterminal",
"description": "Company-scoped POS terminals"
},
{
"name": "Printer",
"description": "Company-scoped receipt and label printers"
},
{
"name": "Ledger",
"description": "Append-only ledger transactions"
},
{
"name": "Stock",
"description": "Manual stock additions and removals"
}
],
"paths": {
@@ -901,6 +909,83 @@
}
}
},
"/stock/adjust": {
"post": {
"tags": [
"Stock"
],
"summary": "Adjust stock manually",
"description": "Writes signed (+ or -) entries to the append-only ledger under an implicit manifest\nof type \"adjustment\", allocating a number from the \"adjustment\" number scheme.\n",
"security": [
{
"cookieAuth": []
}
],
"x-markdown": "stock/adjust.md",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/StockAdjustmentInput"
}
}
}
},
"responses": {
"201": {
"description": "Stock adjusted successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/StockAdjustmentResult"
}
}
}
},
"400": {
"description": "Missing fields, invalid amount, or no company selected",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Article or warehouse not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/quote": {
"get": {
"tags": [
@@ -1361,6 +1446,560 @@
}
}
},
"/printer": {
"get": {
"tags": [
"Printer"
],
"summary": "List printers",
"description": "Lists printers for the selected company, ordered by sort and id.",
"security": [
{
"cookieAuth": []
}
],
"x-markdown": "printer/list.md",
"responses": {
"200": {
"description": "List of printers",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"printers": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Printer"
}
}
}
}
}
}
},
"400": {
"description": "No company selected",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"tags": [
"Printer"
],
"summary": "Create printer",
"description": "Creates a new printer for the selected company.\n`type` must be `\"esc/pos\"` (lines) or `\"zpl\"` (pages).\n",
"security": [
{
"cookieAuth": []
}
],
"x-markdown": "printer/create.md",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PrinterCreateInput"
}
}
}
},
"responses": {
"201": {
"description": "Created printer",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"printer": {
"$ref": "#/components/schemas/Printer"
}
}
}
}
}
},
"400": {
"description": "Invalid input or missing fields",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/printer/order": {
"put": {
"tags": [
"Printer"
],
"summary": "Reorder printers",
"description": "Reorders printers for the selected company.\n`printerIds` must include all existing printer IDs exactly once.\n",
"security": [
{
"cookieAuth": []
}
],
"x-markdown": "printer/order.md",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"printerIds"
],
"properties": {
"printerIds": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
}
}
},
"responses": {
"200": {
"description": "Applied printer order",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"printerIds": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
}
}
},
"400": {
"description": "Invalid printer order or no company selected",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/printer/{id}": {
"get": {
"tags": [
"Printer"
],
"summary": "Get printer by ID",
"description": "Retrieves a single printer for the authenticated user's selected company.",
"security": [
{
"cookieAuth": []
}
],
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"schema": {
"type": "integer"
},
"description": "Printer ID"
}
],
"x-markdown": "printer/get.md",
"responses": {
"200": {
"description": "Printer details",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"printer": {
"$ref": "#/components/schemas/Printer"
}
}
}
}
}
},
"400": {
"description": "Invalid ID or no company selected",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Printer not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"patch": {
"tags": [
"Printer"
],
"summary": "Update printer (partial)",
"description": "Updates specified fields of an existing printer for the selected company.",
"security": [
{
"cookieAuth": []
}
],
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"schema": {
"type": "integer"
},
"description": "Printer ID"
}
],
"x-markdown": "printer/update.md",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PrinterUpdateInput"
}
}
}
},
"responses": {
"200": {
"description": "Updated printer",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"printer": {
"$ref": "#/components/schemas/Printer"
}
}
}
}
}
},
"400": {
"description": "Invalid input",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Printer not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"put": {
"tags": [
"Printer"
],
"summary": "Update printer",
"description": "Updates specified fields of an existing printer for the selected company.",
"security": [
{
"cookieAuth": []
}
],
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"schema": {
"type": "integer"
},
"description": "Printer ID"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PrinterUpdateInput"
}
}
}
},
"responses": {
"200": {
"description": "Updated printer",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"printer": {
"$ref": "#/components/schemas/Printer"
}
}
}
}
}
},
"400": {
"description": "Invalid input",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Printer not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"delete": {
"tags": [
"Printer"
],
"summary": "Delete printer",
"description": "Deletes a printer for the authenticated user's selected company.",
"security": [
{
"cookieAuth": []
}
],
"parameters": [
{
"in": "path",
"name": "id",
"required": true,
"schema": {
"type": "integer"
},
"description": "Printer ID"
}
],
"x-markdown": "printer/delete.md",
"responses": {
"204": {
"description": "Printer deleted"
},
"400": {
"description": "Invalid ID or no company selected",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Printer not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/posterminal": {
"get": {
"tags": [
@@ -11071,6 +11710,208 @@
"description": "Transaction memo / details"
}
}
},
"Printer": {
"type": "object",
"required": [
"id",
"company_id",
"address",
"type",
"sort"
],
"properties": {
"id": {
"type": "integer"
},
"company_id": {
"type": "integer"
},
"address": {
"type": "string",
"description": "Printer network address or hostname"
},
"type": {
"type": "string",
"enum": [
"esc/pos",
"zpl"
],
"description": "Printer type (\"esc/pos\" for lines or \"zpl\" for pages)"
},
"model": {
"type": "string",
"nullable": true,
"description": "Printer model name"
},
"serial": {
"type": "string",
"nullable": true,
"description": "Printer serial number"
},
"sort": {
"type": "integer",
"description": "Sort order"
},
"desc": {
"type": "string",
"nullable": true,
"description": "Printer description"
}
}
},
"PrinterCreateInput": {
"type": "object",
"required": [
"address",
"type"
],
"properties": {
"address": {
"type": "string",
"description": "Printer network address or hostname"
},
"type": {
"type": "string",
"enum": [
"esc/pos",
"zpl"
],
"description": "Printer type (\"esc/pos\" for lines or \"zpl\" for pages)"
},
"model": {
"type": "string",
"nullable": true
},
"serial": {
"type": "string",
"nullable": true
},
"sort": {
"type": "integer"
},
"desc": {
"type": "string",
"nullable": true
}
}
},
"PrinterUpdateInput": {
"type": "object",
"properties": {
"address": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"esc/pos",
"zpl"
]
},
"model": {
"type": "string",
"nullable": true
},
"serial": {
"type": "string",
"nullable": true
},
"sort": {
"type": "integer"
},
"desc": {
"type": "string",
"nullable": true
}
}
},
"StockAdjustmentInput": {
"type": "object",
"properties": {
"sku": {
"type": "string",
"description": "Article SKU (for single-item adjustment)"
},
"warehouseId": {
"type": "integer",
"description": "Target warehouse ID"
},
"amount": {
"type": "number",
"description": "Signed adjustment quantity (+ to add, - to remove)"
},
"text": {
"type": "string",
"nullable": true,
"description": "Reason or memo"
},
"lines": {
"type": "array",
"description": "Batch adjustment lines",
"items": {
"type": "object",
"required": [
"sku",
"amount"
],
"properties": {
"sku": {
"type": "string"
},
"warehouseId": {
"type": "integer"
},
"amount": {
"type": "number"
},
"text": {
"type": "string"
}
}
}
}
}
},
"StockAdjustmentResult": {
"type": "object",
"properties": {
"manifest": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"number": {
"type": "string"
},
"type": {
"type": "string",
"example": "adjustment"
},
"date": {
"type": "string",
"format": "date-time"
},
"createdAt": {
"type": "string",
"format": "date-time"
}
}
},
"lines": {
"type": "array",
"items": {
"type": "object"
}
},
"ledger": {
"type": "array",
"items": {
"$ref": "#/components/schemas/LedgerEntry"
}
}
}
}
}
}

View File

@@ -0,0 +1,58 @@
# `PUT /printer/{id}`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Update printer
Updates specified fields of an existing printer for the selected company.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Printer ID |
## Body (JSON)
```json
{
"address": "…",
"type": "esc/pos",
"model": "…",
"serial": "…",
"sort": 1,
"desc": "…"
}
```
## Response `200`
Updated printer
```json
{
"printer": {
"id": 1,
"company_id": 1,
"address": "…",
"type": "esc/pos",
"model": "…",
"serial": "…",
"sort": 1,
"desc": "…"
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid input — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Printer not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,53 @@
# `POST /printer`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Create printer
Creates a new printer for the selected company.
`type` must be `"esc/pos"` (lines) or `"zpl"` (pages).
## Body (JSON)
```json
{
"address": "…",
"type": "esc/pos",
"model": "…",
"serial": "…",
"sort": 1,
"desc": "…"
}
```
## Response `201`
Created printer
```json
{
"printer": {
"id": 1,
"company_id": 1,
"address": "…",
"type": "esc/pos",
"model": "…",
"serial": "…",
"sort": 1,
"desc": "…"
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid input or missing fields — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,32 @@
# `DELETE /printer/{id}`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Delete printer
Deletes a printer for the authenticated user's selected company.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Printer ID |
## Response `204`
Printer deleted
_No content_
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid ID or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Printer not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,45 @@
# `GET /printer/{id}`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Get printer by ID
Retrieves a single printer for the authenticated user's selected company.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Printer ID |
## Response `200`
Printer details
```json
{
"printer": {
"id": 1,
"company_id": 1,
"address": "…",
"type": "esc/pos",
"model": "…",
"serial": "…",
"sort": 1,
"desc": "…"
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid ID or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Printer not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,40 @@
# `GET /printer`
Protected. Requires a valid session cookie (`credentials: 'include'`).
List printers
Lists printers for the selected company, ordered by sort and id.
## Response `200`
List of printers
```json
{
"printers": [
{
"id": 1,
"company_id": 1,
"address": "…",
"type": "esc/pos",
"model": "…",
"serial": "…",
"sort": 1,
"desc": "…"
}
]
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | No company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,43 @@
# `PUT /printer/order`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Reorder printers
Reorders printers for the selected company.
`printerIds` must include all existing printer IDs exactly once.
## Body (JSON)
```json
{
"printerIds": [
1
]
}
```
## Response `200`
Applied printer order
```json
{
"printerIds": [
1
]
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid printer order or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,58 @@
# `PATCH /printer/{id}`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Update printer (partial)
Updates specified fields of an existing printer for the selected company.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Printer ID |
## Body (JSON)
```json
{
"address": "…",
"type": "esc/pos",
"model": "…",
"serial": "…",
"sort": 1,
"desc": "…"
}
```
## Response `200`
Updated printer
```json
{
"printer": {
"id": 1,
"company_id": 1,
"address": "…",
"type": "esc/pos",
"model": "…",
"serial": "…",
"sort": 1,
"desc": "…"
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid input — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Printer not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,73 @@
# `POST /stock/adjust`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Adjust stock manually
Writes signed (+ or -) entries to the append-only ledger under an implicit manifest
of type "adjustment", allocating a number from the "adjustment" number scheme.
## Body (JSON)
```json
{
"sku": "…",
"warehouseId": 1,
"amount": 1,
"text": "…",
"lines": [
{
"sku": "…",
"warehouseId": 1,
"amount": 1,
"text": "…"
}
]
}
```
## Response `201`
Stock adjusted successfully
```json
{
"manifest": {
"id": 1,
"number": "…",
"type": "adjustment",
"date": "2026-08-10T00:00:00.000Z",
"createdAt": "2026-08-10T00:00:00.000Z"
},
"lines": [
{}
],
"ledger": [
{
"id": 1,
"manifestarticle_id": 1,
"transaction_type": "…",
"amount": 1,
"transaction_text": "…",
"hash_version": 1,
"prev_hash": "…",
"sku": "…",
"created_at": "2026-08-10T00:00:00.000Z"
}
]
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Missing fields, invalid amount, or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Article or warehouse not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._