Refactor API client and stock management logic for improved clarity, error handling, and support for additional stock types.

This commit is contained in:
2026-04-06 10:30:37 +02:00
parent 929ee6557a
commit 155c7a65d6
8 changed files with 364 additions and 103 deletions
+11 -5
View File
@@ -67,7 +67,7 @@ Then configure your web server to serve `/var/www/lonc` as a static site.
The application does not require build-time environment variables for the Tryton connection. Users configure the following in the login screen:
- Tryton server base URL
- Tryton server base URL (optional, leave empty for same-origin deployment)
- database name
- user login
@@ -77,6 +77,8 @@ Authentication is done with Tryton user application keys for the `kitchen` appli
If the frontend and Tryton backend are served from different origins, the Tryton server must allow cross-origin requests from the frontend origin.
If Lonc is served by the same nginx origin as the API, leave the server URL empty in the app settings so requests stay same-origin and avoid unnecessary browser CORS checks.
At minimum, production should ensure:
- `Authorization` headers are accepted for API requests
@@ -143,8 +145,6 @@ Expected shapes today:
`/{database}/kitchen/{kitchen_id}/{resource}`
- User application key management uses:
`/{database}/user/application/`
- Non-kitchen-scoped authenticated resources currently assume:
`/{database}/{resource}`
- `POST /{database}/user/application/`
Sends `{ user, application: "kitchen" }` and returns the application key as a JSON string.
@@ -155,14 +155,20 @@ Expected shapes today:
Returns `{ data: [...] }` or `{ kitchens: [...] }`.
- `GET /{database}/kitchen/items?search_name=...`
Returns item definitions for autocomplete.
- `GET /{database}/kitchen/items`
Returns the current stock review list.
- `GET /{database}/kitchen/items/{uuid_b64}`
Returns one item detail payload.
- `POST /{database}/kitchen/items?label=1`
Creates a stock item plus label-related output on the backend side.
- `POST /{database}/kitchen/items?label=1&preview=1`
Returns an image blob, `{ imageUrl }`, or `{ imageSvg }` for in-browser preview.
- `POST /{database}/kitchen/items/{uuid_b64}/stock`
Updates measured or descriptive stock state using `{ quantity }` or `{ level }`.
- `DELETE /{database}/kitchen/items/{uuid_b64}`
Marks an individual stock item gone.
- `GET /{database}/kitchen/locations`
Returns a nested location tree.
- `GET /{database}/kitchen/{kitchen_id}/stock`, `GET /{database}/kitchen/{kitchen_id}/stock/:id`, `POST /{database}/kitchen/{kitchen_id}/stock/:id/adjust`
Back the stock overview, creation, and adjustment workflows.
## Notes