This commit is contained in:
seb
2026-10-03 23:13:36 +02:00
parent 1786879c4e
commit 9a7f345d8b
39 changed files with 4611 additions and 50 deletions

View File

@@ -4,7 +4,7 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
List label templates
Lists all ZPL label templates for the selected company. The `thumb` field is returned as a base64-encoded PNG string when present. `content.objects` is omitted to reduce payload size.
Lists all ZPL label templates for the selected company. The `thumb` field is returned as a base64-encoded PNG string when present. The `content` field is omitted to reduce payload size (use GET /labeltemplate/{id} for it).
## Response `200`

View File

@@ -0,0 +1,39 @@
# `GET /modelconversation`
Protected. Requires a valid session cookie (`credentials: 'include'`).
List conversations
Lists the authenticated user's model conversations in the selected company, most recently updated first.
## Response `200`
List of conversations
```json
{
"conversations": [
{
"id": 1,
"companyuser_id": 1,
"provider": "…",
"model": "…",
"created_at": "…",
"updated_at": "…",
"state": "idle"
}
]
}
```
## 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,51 @@
# `POST /modelconversation`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Create conversation
Creates a new conversation in state `idle`.
## Body (JSON)
| Field | Required | Type | Description |
|-------|----------|------|-------------|
| `provider` | yes | string | |
| `model` | yes | string | |
```json
{
"provider": "…",
"model": "…"
}
```
## Response `201`
Created conversation
```json
{
"conversation": {
"id": 1,
"companyuser_id": 1,
"provider": "…",
"model": "…",
"created_at": "…",
"updated_at": "…",
"state": "idle"
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid input 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,32 @@
# `DELETE /modelconversation/{id}`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Delete conversation
Deletes one of the authenticated user's model conversations and all its messages.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Conversation ID |
## Response `204`
Conversation deleted
_No content_
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid ID or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Conversation not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,44 @@
# `GET /modelconversation/{id}`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Get conversation
Gets details and current state of one of the authenticated user's model conversations.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Conversation ID |
## Response `200`
Conversation details
```json
{
"conversation": {
"id": 1,
"companyuser_id": 1,
"provider": "…",
"model": "…",
"created_at": "…",
"updated_at": "…",
"state": "idle"
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid ID or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Conversation not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,44 @@
# `GET /modelconversation/{id}/message`
Protected. Requires a valid session cookie (`credentials: 'include'`).
List conversation messages
Lists messages of one of the user's own conversations, oldest first.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Conversation ID |
## Response `200`
List of messages
```json
{
"messages": [
{
"id": 1,
"conversation_id": 1,
"created_at": "…",
"role": "system",
"message": "…"
}
]
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid ID or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Conversation not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,65 @@
# `POST /modelconversation/{id}/message`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Post a user message
Appends a message with role `user` to the conversation.
Refused with 409 unless the conversation state is `idle`.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Conversation ID |
## Body (JSON)
| Field | Required | Type | Description |
|-------|----------|------|-------------|
| `message` | no | string | User message text or fallback content |
| `role` | no | string | Message role ('user' or 'tool') |
| `tool_call_id` | no | string | Target tool call ID when responding to a tool like ask_user |
| `content` | no | | Tool response content payload |
| `answer` | no | | Shorthand answer for ask_user response |
```json
{
"message": "…",
"role": "user",
"tool_call_id": "…",
"content": "…",
"answer": "…"
}
```
## Response `201`
Created message
```json
{
"message": {
"id": 1,
"conversation_id": 1,
"created_at": "…",
"role": "system",
"message": "…"
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid ID, empty message or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Conversation not found — `{"error":"…"}` |
| 409 | Conversation is not idle — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,37 @@
# `GET /modelconversation/{id}/stream`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Stream conversation events (SSE)
Opens a Server-Sent Events stream for the specified conversation.
Streams `message` events (persisted user/assistant messages), live `delta`
text chunks of the model answer, and `state` events (`thinking`, `working`,
`done`). The SSE states are not stored; the database only knows `idle`/`busy`.
`done` carries `usage` (`input`, `cached`, `output`, `cost`) on success or
`error` (string) if the run failed.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `id` | yes | integer | Conversation ID |
## Response `200`
SSE stream (`text/event-stream`). Emits `state`, `delta`, and `message` events.
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid ID or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Conversation not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,62 @@
# `GET /public/{companyId}/articles`
Public. No cookie required.
List public articles
Returns a paginated list of catalog articles for the specified company, optionally filtered by category.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `companyId` | yes | integer | Company ID |
## Query parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `categoryId` | no | integer | Optional category ID to filter by |
| `search` | no | string | Search query for name or SKU |
| `limit` | no | integer | Number of articles to return (max 200) |
| `offset` | no | integer | Number of articles to skip |
## Response `200`
Articles list
```json
{
"articles": [
{
"id": 1,
"sku": "…",
"name": "…",
"slug": "…",
"net": 1,
"taxRate": 1,
"gross": 1,
"trackStock": true,
"brand": {
"id": 1,
"name": "…"
},
"fullHash": "…",
"thumbW": 1,
"thumbH": 1,
"thumbHash": "…"
}
]
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid parameters — `{"error":"…"}` |
| 404 | Company not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,64 @@
# `GET /public/{companyId}/articles/{sku}`
Public. No cookie required.
Get public article detail
Returns detailed public catalog data for a single article identified by SKU.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `companyId` | yes | integer | Company ID |
| `sku` | yes | string | Article SKU |
## Response `200`
Article detail
```json
{
"article": {
"id": 1,
"sku": "…",
"name": "…",
"slug": "…",
"description": "…",
"unitamount": 1,
"weight": 1,
"trackStock": true,
"unit": {},
"brand": {},
"price": {},
"prices": [
{}
],
"categories": [
{}
],
"photos": [
{}
],
"eans": [
"…"
],
"isFather": true,
"fatherSku": "…",
"variants": [
{}
]
}
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid parameters — `{"error":"…"}` |
| 404 | Article or Company not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -0,0 +1,46 @@
# `GET /public/{companyId}/categories`
Public. No cookie required.
List public categories
Returns the category tree for the specified company.
## Path parameters
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `companyId` | yes | integer | Company ID |
## Response `200`
Category list
```json
{
"categories": [
{
"id": 1,
"parentId": 1,
"sort": 1,
"name": "…",
"slug": "…",
"fullHash": "…",
"thumbW": 1,
"thumbH": 1,
"thumbHash": "…"
}
]
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | Invalid parameters — `{"error":"…"}` |
| 404 | Company not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._