Align store calls with selected-company scoping and add entity numbers.
Drop companyId from company-scoped store wrappers and routes, add GET /entity/next-number plus optional number on entity create/update, and document dashdbschema API.md lookup in sibling-repos.
This commit is contained in:
@@ -77,6 +77,7 @@ Generated from `@openapi` annotations in [`src/api/routes/`](../../src/api/route
|
||||
| [`routes/delivery/update.md`](routes/delivery/update.md) | `PATCH /delivery/{id}` |
|
||||
| [`routes/entity/list.md`](routes/entity/list.md) | `GET /entity` |
|
||||
| [`routes/entity/create.md`](routes/entity/create.md) | `POST /entity` |
|
||||
| [`routes/entity/next-number.md`](routes/entity/next-number.md) | `GET /entity/next-number` |
|
||||
| [`routes/entity/address/list.md`](routes/entity/address/list.md) | `GET /entity/{entityId}/address` |
|
||||
| [`routes/entity/address/create.md`](routes/entity/address/create.md) | `POST /entity/{entityId}/address` |
|
||||
| [`routes/entity/address/delete.md`](routes/entity/address/delete.md) | `DELETE /entity/{entityId}/address/{id}` |
|
||||
|
||||
@@ -3299,7 +3299,7 @@
|
||||
"Entity"
|
||||
],
|
||||
"summary": "List entities",
|
||||
"description": "Lists entities for the selected company. Optional `customergroupId`\nquery filters to one group (must belong to the company).\n",
|
||||
"description": "Lists entities for the selected company. Optional `customergroupId`\nfilters to one group. Optional `role=customer` excludes Lieferanten/POS\ngroups (for quote/order pickers). `role` wins when both are set.\n",
|
||||
"security": [
|
||||
{
|
||||
"cookieAuth": []
|
||||
@@ -3314,6 +3314,17 @@
|
||||
"schema": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"in": "query",
|
||||
"name": "role",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"customer"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
@@ -3336,7 +3347,7 @@
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "No company selected or invalid customergroupId",
|
||||
"description": "No company selected, invalid customergroupId, or invalid role",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
@@ -3382,7 +3393,7 @@
|
||||
"Entity"
|
||||
],
|
||||
"summary": "Create entity",
|
||||
"description": "Creates an entity in a company customer group and writes `entityhistory` (`Erstellt`).\n",
|
||||
"description": "Creates an entity in a company customer group and writes `entityhistory` (`Erstellt`).\nOptional `number`: omit to allocate the next customer number (`type` entity).\n",
|
||||
"security": [
|
||||
{
|
||||
"cookieAuth": []
|
||||
@@ -3409,12 +3420,17 @@
|
||||
"firstName": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"number": {
|
||||
"type": "string",
|
||||
"description": "Customer number; omit to auto-allocate"
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"customergroupId": 1,
|
||||
"name": "Müller",
|
||||
"firstName": "Anna"
|
||||
"firstName": "Anna",
|
||||
"number": "10042"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3437,7 +3453,7 @@
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Name required or no company selected",
|
||||
"description": "Name/number required or no company selected",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
@@ -3475,6 +3491,94 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"409": {
|
||||
"description": "Number already in use",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/entity/next-number": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Entity"
|
||||
],
|
||||
"summary": "Peek next customer number",
|
||||
"description": "Returns the next customer number that would be allocated (`type` entity)\nwithout consuming it. Use on the customer add form.\n",
|
||||
"security": [
|
||||
{
|
||||
"cookieAuth": []
|
||||
}
|
||||
],
|
||||
"x-markdown": "entity/next-number.md",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Next number",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"number"
|
||||
],
|
||||
"properties": {
|
||||
"number": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"number": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Company not found",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3565,7 +3669,7 @@
|
||||
"Entity"
|
||||
],
|
||||
"summary": "Update entity",
|
||||
"description": "Patches `name` and/or `firstName`. Writes `entityhistory` when values change.\n",
|
||||
"description": "Patches fields that are present (`name`, `firstName`, `number`).\n`number` is only changed when the key is present (no auto-allocate).\nWrites `entityhistory` when values change.\n",
|
||||
"security": [
|
||||
{
|
||||
"cookieAuth": []
|
||||
@@ -3595,11 +3699,16 @@
|
||||
"firstName": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
},
|
||||
"number": {
|
||||
"type": "string",
|
||||
"nullable": true
|
||||
}
|
||||
},
|
||||
"example": {
|
||||
"name": "Müller",
|
||||
"firstName": "Anna"
|
||||
"firstName": "Anna",
|
||||
"number": "10042"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3622,7 +3731,7 @@
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Name required, invalid id, or no company selected",
|
||||
"description": "Name/number required, invalid id, or no company selected",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
@@ -3660,6 +3769,16 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"409": {
|
||||
"description": "Number already in use",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -8070,6 +8189,7 @@
|
||||
"customergroupId",
|
||||
"firstName",
|
||||
"name",
|
||||
"number",
|
||||
"createdAt",
|
||||
"updatedAt"
|
||||
],
|
||||
@@ -8087,6 +8207,11 @@
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"number": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Customer number (null for suppliers)"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
|
||||
@@ -5,6 +5,7 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
|
||||
Create entity
|
||||
|
||||
Creates an entity in a company customer group and writes `entityhistory` (`Erstellt`).
|
||||
Optional `number`: omit to allocate the next customer number (`type` entity).
|
||||
|
||||
|
||||
## Body (JSON)
|
||||
@@ -13,7 +14,8 @@ Creates an entity in a company customer group and writes `entityhistory` (`Erste
|
||||
{
|
||||
"customergroupId": 1,
|
||||
"name": "Müller",
|
||||
"firstName": "Anna"
|
||||
"firstName": "Anna",
|
||||
"number": "10042"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -28,6 +30,7 @@ Created entity
|
||||
"customergroupId": 1,
|
||||
"firstName": "…",
|
||||
"name": "…",
|
||||
"number": "…",
|
||||
"createdAt": "2026-08-10T00:00:00.000Z",
|
||||
"updatedAt": "2026-08-10T00:00:00.000Z"
|
||||
}
|
||||
@@ -38,10 +41,11 @@ Created entity
|
||||
|
||||
| Status | Description |
|
||||
|--------|-------------|
|
||||
| 400 | Name required or no company selected — `{"error":"…"}` |
|
||||
| 400 | Name/number required or no company selected — `{"error":"…"}` |
|
||||
| 401 | Unauthorized — `{"error":"…"}` |
|
||||
| 403 | Not authorized — `{"error":"…"}` |
|
||||
| 404 | Company or customer group not found — `{"error":"…"}` |
|
||||
| 409 | Number already in use — `{"error":"…"}` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ Entity
|
||||
"customergroupId": 1,
|
||||
"firstName": "…",
|
||||
"name": "…",
|
||||
"number": "…",
|
||||
"createdAt": "2026-08-10T00:00:00.000Z",
|
||||
"updatedAt": "2026-08-10T00:00:00.000Z"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
|
||||
List entities
|
||||
|
||||
Lists entities for the selected company. Optional `customergroupId`
|
||||
query filters to one group (must belong to the company).
|
||||
filters to one group. Optional `role=customer` excludes Lieferanten/POS
|
||||
groups (for quote/order pickers). `role` wins when both are set.
|
||||
|
||||
|
||||
## Query parameters
|
||||
@@ -13,6 +14,7 @@ query filters to one group (must belong to the company).
|
||||
| Param | Required | Type | Description |
|
||||
|-------|----------|------|-------------|
|
||||
| `customergroupId` | no | integer | |
|
||||
| `role` | no | string | |
|
||||
|
||||
## Response `200`
|
||||
|
||||
@@ -26,6 +28,7 @@ Entity list
|
||||
"customergroupId": 1,
|
||||
"firstName": "…",
|
||||
"name": "…",
|
||||
"number": "…",
|
||||
"createdAt": "2026-08-10T00:00:00.000Z",
|
||||
"updatedAt": "2026-08-10T00:00:00.000Z"
|
||||
}
|
||||
@@ -37,7 +40,7 @@ Entity list
|
||||
|
||||
| Status | Description |
|
||||
|--------|-------------|
|
||||
| 400 | No company selected or invalid customergroupId — `{"error":"…"}` |
|
||||
| 400 | No company selected, invalid customergroupId, or invalid role — `{"error":"…"}` |
|
||||
| 401 | Unauthorized — `{"error":"…"}` |
|
||||
| 403 | Not authorized — `{"error":"…"}` |
|
||||
| 404 | Company or customer group not found — `{"error":"…"}` |
|
||||
|
||||
32
docs/api/routes/entity/next-number.md
Normal file
32
docs/api/routes/entity/next-number.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# `GET /entity/next-number`
|
||||
|
||||
Protected. Requires a valid session cookie (`credentials: 'include'`).
|
||||
|
||||
Peek next customer number
|
||||
|
||||
Returns the next customer number that would be allocated (`type` entity)
|
||||
without consuming it. Use on the customer add form.
|
||||
|
||||
|
||||
## Response `200`
|
||||
|
||||
Next number
|
||||
|
||||
```json
|
||||
{
|
||||
"number": "…"
|
||||
}
|
||||
```
|
||||
|
||||
## Errors
|
||||
|
||||
| Status | Description |
|
||||
|--------|-------------|
|
||||
| 400 | No company selected — `{"error":"…"}` |
|
||||
| 401 | Unauthorized — `{"error":"…"}` |
|
||||
| 403 | Not authorized — `{"error":"…"}` |
|
||||
| 404 | Company not found — `{"error":"…"}` |
|
||||
|
||||
---
|
||||
|
||||
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._
|
||||
@@ -4,7 +4,9 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
|
||||
|
||||
Update entity
|
||||
|
||||
Patches `name` and/or `firstName`. Writes `entityhistory` when values change.
|
||||
Patches fields that are present (`name`, `firstName`, `number`).
|
||||
`number` is only changed when the key is present (no auto-allocate).
|
||||
Writes `entityhistory` when values change.
|
||||
|
||||
|
||||
## Path parameters
|
||||
@@ -18,7 +20,8 @@ Patches `name` and/or `firstName`. Writes `entityhistory` when values change.
|
||||
```json
|
||||
{
|
||||
"name": "Müller",
|
||||
"firstName": "Anna"
|
||||
"firstName": "Anna",
|
||||
"number": "10042"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -33,6 +36,7 @@ Updated entity
|
||||
"customergroupId": 1,
|
||||
"firstName": "…",
|
||||
"name": "…",
|
||||
"number": "…",
|
||||
"createdAt": "2026-08-10T00:00:00.000Z",
|
||||
"updatedAt": "2026-08-10T00:00:00.000Z"
|
||||
}
|
||||
@@ -43,10 +47,11 @@ Updated entity
|
||||
|
||||
| Status | Description |
|
||||
|--------|-------------|
|
||||
| 400 | Name required, invalid id, or no company selected — `{"error":"…"}` |
|
||||
| 400 | Name/number required, invalid id, or no company selected — `{"error":"…"}` |
|
||||
| 401 | Unauthorized — `{"error":"…"}` |
|
||||
| 403 | Not authorized — `{"error":"…"}` |
|
||||
| 404 | Entity or company not found — `{"error":"…"}` |
|
||||
| 409 | Number already in use — `{"error":"…"}` |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user