u
This commit is contained in:
@@ -84,6 +84,8 @@ Generated from `@openapi` annotations in [`src/api/routes/`](../../src/api/route
|
||||
| [`routes/brand/list.md`](routes/brand/list.md) | `GET /brand` |
|
||||
| [`routes/brand/upsert.md`](routes/brand/upsert.md) | `PUT /brand` |
|
||||
| [`routes/brand/delete.md`](routes/brand/delete.md) | `DELETE /brand/{id}` |
|
||||
| [`routes/brand/_id/image.delete.md`](routes/brand/_id/image.delete.md) | `DELETE /brand/{id}/image` |
|
||||
| [`routes/brand/_id/image.post.md`](routes/brand/_id/image.post.md) | `POST /brand/{id}/image` |
|
||||
| [`routes/category/create.md`](routes/category/create.md) | `POST /category` |
|
||||
| [`routes/category/export.zip.md`](routes/category/export.zip.md) | `GET /category/export.zip` |
|
||||
| [`routes/category/order.md`](routes/category/order.md) | `PUT /category/order` |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Dash API Routes Overview (All)
|
||||
|
||||
Overview of all 180 API endpoints across all modules.
|
||||
Overview of all 182 API endpoints across all modules.
|
||||
|
||||
### Notation
|
||||
|
||||
@@ -10,18 +10,18 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
||||
### Reusable types
|
||||
|
||||
- `T1` = `{ article: T2 }`
|
||||
- `T2` = `{ id: int, sku: str, name: str, slug: str, track_stock: bool, unitamount: num, weight: num, unit: obj, brand: obj, categoryIds: int[], photos: T17[], eans: str[], prices: T27[], suppliers: T9[] }`
|
||||
- `T2` = `{ id: int, sku: str, name: str, slug: str, track_stock: bool, unitamount: num, weight: num, unit: obj, brand: obj, categoryIds: int[], photos: T17[], eans: str[], prices: T28[], suppliers: T9[] }`
|
||||
- `T3` = `{ delivery: T4 }`
|
||||
- `T4` = `{ id: int, number: str, type: str, supplierId: int, externalNumber: str, date: str, createdAt: str, ledger: T32, lines: T18[], files: T8[] }`
|
||||
- `T4` = `{ id: int, number: str, type: str, supplierId: int, externalNumber: str, date: str, createdAt: str, ledger: T33, lines: T18[], files: T8[] }`
|
||||
- `T5` = `{ order: T7 }`
|
||||
- `T6` = `{ quote: T7 }`
|
||||
- `T7` = `{ id: int, number: str, type: str, entityId: int, date: str, createdAt: str, lines: T18[] }`
|
||||
- `T8` = `{ id: int, manifestId: int, fileId: int, sort: int, hash: str, mimetype: str, name: str, size: int, created: str, modified: str, thumbavif: str, thumbx: int, thumby: int, meta: obj }`
|
||||
- `T9` = `{ id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T35 }`
|
||||
- `T9` = `{ id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T36 }`
|
||||
- `T10` = `{ ledger: T11[] }`
|
||||
- `T11` = `{ id: int, manifestarticle_id: int, transaction_type: str, amount: num, transaction_text: str, hash_version: int, prev_hash: str, sku: str, created_at: str }`
|
||||
- `T12` = `{ id: int, entityId: int, firstName: str, name: str, street: str, streetNumber: str, zip: str, city: str, county: str, addressType: str }`
|
||||
- `T13` = `{ id: int, name: str, sort: int, exclusive: bool, values: T30[] }`
|
||||
- `T13` = `{ id: int, name: str, sort: int, exclusive: bool, values: T31[] }`
|
||||
- `T14` = `{ entity: T20 }`
|
||||
- `T15` = `{ printer: T21 }`
|
||||
- `T16` = `{ labeltemplate: T23 }`
|
||||
@@ -32,26 +32,27 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
||||
- `T21` = `{ id: int, company_id: int, address: str, type: str, model: str, serial: str, sort: int, desc: str }`
|
||||
- `T22` = `{ amount: num, net: num, taxrate: num, sku?: str, name?: str, pu?: num, rebate?: num, comment?: str }`
|
||||
- `T23` = `{ id: int, name: str, width: num, height: num, dpi: int, type: str, content: obj, thumb: str }`
|
||||
- `T24` = `{ article: T26 }`
|
||||
- `T25` = `{ id: int, iso639: str, name: str, taxrate: num, reducedtaxrate: num }`
|
||||
- `T26` = `{ id: int, categoryId: int, name: str, sku: str, track_stock: bool }`
|
||||
- `T27` = `{ minmultiplier: num, net: num, taxRate: num, customergroupId: int }`
|
||||
- `T28` = `{ id: int, email: str, selectedCompanyId: int, picture: str }`
|
||||
- `T29` = `{ id: int, entityId: int, contactType: str, contact: str }`
|
||||
- `T30` = `{ id: int, attributeId: int, value: str, sort: int }`
|
||||
- `T31` = `{ id: int, name: str, createdAt: str, updatedAt: str }`
|
||||
- `T32` = `{ totalPositions: int, completelyOnLedgerPositions: int }`
|
||||
- `T33` = `{ id: int, name: str, sort: int, exclusive: bool }`
|
||||
- `T34` = `{ warehouse: T36 }`
|
||||
- `T35` = `{ net: num, taxId: int, taxRate: num }`
|
||||
- `T36` = `{ id: int, name: str, sort: int }`
|
||||
- `T37` = `{ id: int, categoryIds: int[] }`
|
||||
- `T24` = `{ id: int, sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }`
|
||||
- `T25` = `{ article: T27 }`
|
||||
- `T26` = `{ id: int, iso639: str, name: str, taxrate: num, reducedtaxrate: num }`
|
||||
- `T27` = `{ id: int, categoryId: int, name: str, sku: str, track_stock: bool }`
|
||||
- `T28` = `{ minmultiplier: num, net: num, taxRate: num, customergroupId: int }`
|
||||
- `T29` = `{ id: int, email: str, selectedCompanyId: int, picture: str }`
|
||||
- `T30` = `{ id: int, entityId: int, contactType: str, contact: str }`
|
||||
- `T31` = `{ id: int, attributeId: int, value: str, sort: int }`
|
||||
- `T32` = `{ id: int, name: str, createdAt: str, updatedAt: str }`
|
||||
- `T33` = `{ totalPositions: int, completelyOnLedgerPositions: int }`
|
||||
- `T34` = `{ id: int, name: str, sort: int, exclusive: bool }`
|
||||
- `T35` = `{ warehouse: T37 }`
|
||||
- `T36` = `{ net: num, taxId: int, taxRate: num }`
|
||||
- `T37` = `{ id: int, name: str, sort: int }`
|
||||
- `T38` = `{ id: int, categoryIds: int[] }`
|
||||
|
||||
### Routes
|
||||
|
||||
#### Create article in category — `POST /article`
|
||||
- Params: `body: { categoryId: int, name: str, track_stock?: bool }`
|
||||
- Returns: `201 T24`
|
||||
- Returns: `201 T25`
|
||||
#### Export articles as ZIP — `GET /article/export.zip`
|
||||
- Params: `query: categoryId?: int`
|
||||
- Returns: `200 zip`
|
||||
@@ -87,10 +88,10 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
||||
- Returns: `200 { children: { id: int, sku: str, name: str, parentsort: int, attributeValueId: int, attributeValue: str }[] }`
|
||||
#### Create and attach a new child article to a parent article — `POST /article/{sku}/children`
|
||||
- Params: `sku: str, body: { attributeValueId?: int, value?: str, name?: str }`
|
||||
- Returns: `201 T24`
|
||||
- Returns: `201 T25`
|
||||
#### Attach an existing article as a child to a parent article — `PUT /article/{sku}/children`
|
||||
- Params: `sku: str, body: { sku: str, attributeValueId?: int, value?: str, reparent?: bool }`
|
||||
- Returns: `200 { article: T26, children: obj[] }`
|
||||
- Returns: `200 { article: T27, children: obj[] }`
|
||||
#### Remove a child article from a parent article — `DELETE /article/{sku}/children/{childSku}`
|
||||
- Params: `sku: str, childSku: str, query: deleteArticle?: bool`
|
||||
- Returns: `200 { success: bool, deleted: bool }`
|
||||
@@ -117,7 +118,7 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
||||
- Returns: `200 { options: obj[] }`
|
||||
#### Toggle parent mode for an article — `POST /article/{sku}/parent`
|
||||
- Params: `sku: str, body: { isParent: bool, attributeNameId?: int }`
|
||||
- Returns: `200 T24`
|
||||
- Returns: `200 T25`
|
||||
#### Replace POS prices by SKU — `PUT /article/{sku}/prices`
|
||||
- Params: `sku: str, body: { prices: { price: num, tax: num, minmultiplier?: num }[] }`
|
||||
- Returns: `200 T1`
|
||||
@@ -165,10 +166,10 @@ _none_
|
||||
- Returns: `200`
|
||||
#### List values for an attribute — `GET /attributename/{attributeId}/value`
|
||||
- Params: `attributeId: int`
|
||||
- Returns: `200 { values: T30[] }`
|
||||
- Returns: `200 { values: T31[] }`
|
||||
#### Create value for an attribute — `POST /attributename/{attributeId}/value`
|
||||
- Params: `attributeId: int, body: { value: str, sort?: int }`
|
||||
- Returns: `201 { attributevalue: T30 }`
|
||||
- Returns: `201 { attributevalue: T31 }`
|
||||
#### Reorder values of an attribute — `PUT /attributename/{attributeId}/value/order`
|
||||
- Params: `attributeId: int, body: { attributevalueIds: int[] }`
|
||||
- Returns: `200`
|
||||
@@ -183,28 +184,34 @@ _none_
|
||||
- Returns: `200`
|
||||
#### Update attribute value — `PATCH /attributevalue/{id}`
|
||||
- Params: `id: int, body: { value?: str, sort?: int }`
|
||||
- Returns: `200 { attributevalue: T30 }`
|
||||
- Returns: `200 { attributevalue: T31 }`
|
||||
#### Login with Google ID token — `POST /auth/login`
|
||||
- Params: `body: { idToken: str }`
|
||||
- Returns: `200 { message: str, user: T28 }`
|
||||
- Returns: `200 { message: str, user: T29 }`
|
||||
#### Logout — `POST /auth/logout`
|
||||
_none_
|
||||
- Returns: `200 { message: str }`
|
||||
#### Current user — `GET /auth/me`
|
||||
_none_
|
||||
- Returns: `200 { user: T28, googleClientId: str }`
|
||||
- Returns: `200 { user: T29, googleClientId: str }`
|
||||
#### Set selected company — `PUT /auth/selected-company`
|
||||
- Params: `body: { companyId: int }`
|
||||
- Returns: `200 { user: T28 }`
|
||||
- Returns: `200 { user: T29 }`
|
||||
#### List brands — `GET /brand`
|
||||
_none_
|
||||
- Returns: `200 { brands: { id: int, name: str, gsprpinfo: str, pics: { id: int, sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[] }[] }`
|
||||
- Returns: `200 { brands: { id: int, name: str, gsprpinfo: str, pics: T24[] }[] }`
|
||||
#### Upsert brand — `PUT /brand`
|
||||
- Params: `body: { name: str, gsprpinfo?: str }`
|
||||
- Returns: `200 { brand: { id: int, name: str, gsprpinfo: str, pics: { id: int, sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[] } }`
|
||||
- Returns: `200 { brand: { id: int, name: str, gsprpinfo: str, pics: T24[] } }`
|
||||
#### Delete brand — `DELETE /brand/{id}`
|
||||
- Params: `id: int`
|
||||
- Returns: `204 void`
|
||||
#### Delete brand image — `DELETE /brand/{id}/image`
|
||||
- Params: `id: int`
|
||||
- Returns: `200 { brand: { id: int, thumbW: int, thumbH: int, thumbHash: str, pics: T24[] } }`
|
||||
#### Add or replace brand image — `POST /brand/{id}/image`
|
||||
- Params: `id: int, image/avif`
|
||||
- Returns: `201 { brand: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T24[] } }`
|
||||
#### Create category — `POST /category`
|
||||
- Params: `body: { parentId: int, name: str }`
|
||||
- Returns: `201 { category: { id: int, parentId: int, sort: int, name: str } }`
|
||||
@@ -249,10 +256,10 @@ _none_
|
||||
- Returns: `200`
|
||||
#### List companies — `GET /company`
|
||||
_none_
|
||||
- Returns: `200 { companies: T25[] }`
|
||||
- Returns: `200 { companies: T26[] }`
|
||||
#### Create company — `POST /company`
|
||||
- Params: `body: { iso639: str, name: str, taxrate: num, reducedtaxrate: num }`
|
||||
- Returns: `201 { company: T25, user: T28 }`
|
||||
- Returns: `201 { company: T26, user: T29 }`
|
||||
#### Get company history — `GET /company/history`
|
||||
- Params: `query: limit?: int`
|
||||
- Returns: `200 { history: { id: int, companyuserId: int, date: str, text: str }[], truncated: bool }`
|
||||
@@ -273,13 +280,13 @@ _none_
|
||||
- Returns: `204 void`
|
||||
#### Update company — `PUT /company/{id}`
|
||||
- Params: `id: int, body: { iso639: str, name: str, taxrate: num, reducedtaxrate: num }`
|
||||
- Returns: `200 { company: T25 }`
|
||||
- Returns: `200 { company: T26 }`
|
||||
#### List customer groups — `GET /customergroup`
|
||||
_none_
|
||||
- Returns: `200 { customergroups: { id: int, name: str, sort: int, editable: bool }[] }`
|
||||
#### Create customer group — `POST /customergroup`
|
||||
- Params: `body: { name: str }`
|
||||
- Returns: `201 { customergroup: T36 }`
|
||||
- Returns: `201 { customergroup: T37 }`
|
||||
#### Reorder customer groups — `PUT /customergroup/order`
|
||||
- Params: `body: { customergroupIds: int[] }`
|
||||
- Returns: `200 { customergroupIds: int[] }`
|
||||
@@ -288,10 +295,10 @@ _none_
|
||||
- Returns: `204 void`
|
||||
#### Update customer group — `PATCH /customergroup/{id}`
|
||||
- Params: `id: int, body: { name: str }`
|
||||
- Returns: `200 { customergroup: T36 }`
|
||||
- Returns: `200 { customergroup: T37 }`
|
||||
#### List deliveries — `GET /delivery`
|
||||
_none_
|
||||
- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int, externalNumber: str, date: str, createdAt: str, ledger: T32 }[] }`
|
||||
- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int, externalNumber: str, date: str, createdAt: str, ledger: T33 }[] }`
|
||||
#### Create delivery — `POST /delivery`
|
||||
- Params: `body: { externalNumber: str, date: str, lines: T22[], supplierId?: int, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: obj }[] }`
|
||||
- Returns: `201 T3`
|
||||
@@ -333,16 +340,16 @@ _none_
|
||||
- Returns: `200 { address: T12 }`
|
||||
#### List entity contacts — `GET /entity/{entityId}/contact`
|
||||
- Params: `entityId: int`
|
||||
- Returns: `200 { contacts: T29[] }`
|
||||
- Returns: `200 { contacts: T30[] }`
|
||||
#### Create entity contact — `POST /entity/{entityId}/contact`
|
||||
- Params: `entityId: int, body: { contactType: str, contact: str }`
|
||||
- Returns: `201 { contact: T29 }`
|
||||
- Returns: `201 { contact: T30 }`
|
||||
#### Delete entity contact — `DELETE /entity/{entityId}/contact/{id}`
|
||||
- Params: `entityId: int, id: int`
|
||||
- Returns: `204 void`
|
||||
#### Update entity contact — `PATCH /entity/{entityId}/contact/{id}`
|
||||
- Params: `entityId: int, id: int, body: { contactType?: str, contact?: str }`
|
||||
- Returns: `200 { contact: T29 }`
|
||||
- Returns: `200 { contact: T30 }`
|
||||
#### Delete entity — `DELETE /entity/{id}`
|
||||
- Params: `id: int`
|
||||
- Returns: `204 void`
|
||||
@@ -444,16 +451,16 @@ _none_
|
||||
- Returns: `204 void`
|
||||
#### Disable all categories on terminal — `DELETE /posterminal/{id}/all`
|
||||
- Params: `id: int`
|
||||
- Returns: `200 T37`
|
||||
- Returns: `200 T38`
|
||||
#### Enable all categories on terminal — `PUT /posterminal/{id}/all`
|
||||
- Params: `id: int`
|
||||
- Returns: `200 T37`
|
||||
- Returns: `200 T38`
|
||||
#### Disable category on terminal — `DELETE /posterminal/{id}/category/{categoryId}`
|
||||
- Params: `id: int, categoryId: int`
|
||||
- Returns: `200 T37`
|
||||
- Returns: `200 T38`
|
||||
#### Enable category on terminal — `PUT /posterminal/{id}/category/{categoryId}`
|
||||
- Params: `id: int, categoryId: int`
|
||||
- Returns: `200 T37`
|
||||
- Returns: `200 T38`
|
||||
#### List printers — `GET /printer`
|
||||
_none_
|
||||
- Returns: `200 { printers: T21[] }`
|
||||
@@ -477,10 +484,10 @@ _none_
|
||||
- Returns: `200 T15`
|
||||
#### List property names — `GET /propertyname`
|
||||
_none_
|
||||
- Returns: `200 { propertynames: T33[] }`
|
||||
- Returns: `200 { propertynames: T34[] }`
|
||||
#### Create property name — `POST /propertyname`
|
||||
- Params: `body: { name: str, sort?: int, exclusive?: bool }`
|
||||
- Returns: `201 { propertyname: T33 }`
|
||||
- Returns: `201 { propertyname: T34 }`
|
||||
#### Reorder property names — `PUT /propertyname/order`
|
||||
- Params: `body: { propertynameIds: int[] }`
|
||||
- Returns: `200`
|
||||
@@ -489,7 +496,7 @@ _none_
|
||||
- Returns: `200`
|
||||
#### Update property name — `PATCH /propertyname/{id}`
|
||||
- Params: `id: int, body: { name?: str, sort?: int, exclusive?: bool }`
|
||||
- Returns: `200 { propertyname: T33 }`
|
||||
- Returns: `200 { propertyname: T34 }`
|
||||
#### List public articles — `GET /public/{companyId}/articles`
|
||||
- Params: `companyId: int, query: categoryId?: int, search?: str, limit?: int, offset?: int`
|
||||
- Returns: `200 { articles: { id: int, sku: str, name: str, slug: str, net: num, taxRate: num, gross: num, trackStock: bool, brand: { id: int, name: str }, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[] }`
|
||||
@@ -525,22 +532,22 @@ _none_
|
||||
- Returns: `201 { manifest: { id: int, number: str, type: str, date: str, createdAt: str }, lines: obj[], ledger: T11[] }`
|
||||
#### List suppliers — `GET /supplier`
|
||||
_none_
|
||||
- Returns: `200 { suppliers: T31[] }`
|
||||
- Returns: `200 { suppliers: T32[] }`
|
||||
#### Create supplier — `POST /supplier`
|
||||
- Params: `body: { name: str }`
|
||||
- Returns: `201 { supplier: T31 }`
|
||||
- Returns: `201 { supplier: T32 }`
|
||||
#### Delete supplier — `DELETE /supplier/{id}`
|
||||
- Params: `id: int`
|
||||
- Returns: `204 void`
|
||||
#### Update supplier — `PATCH /supplier/{id}`
|
||||
- Params: `id: int, body: { name: str }`
|
||||
- Returns: `200 { supplier: T31 }`
|
||||
- Returns: `200 { supplier: T32 }`
|
||||
#### List supplier articles by SKUs — `GET /supplier/{id}/articles`
|
||||
- Params: `id: int, query: skus?: string`
|
||||
- Returns: `200 { articles: { id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T35, article: { id: int, sku: str, name: str, slug: str, photos: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans: str[] } }[] }`
|
||||
- Returns: `200 { articles: { id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T36, article: { id: int, sku: str, name: str, slug: str, photos: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans: str[] } }[] }`
|
||||
#### Query supplier articles by SKUs (bulk) — `POST /supplier/{id}/articles`
|
||||
- Params: `id: int, body?: { skus?: str[] }`
|
||||
- Returns: `200 { articles: { id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T35, article: { id: int, sku: str, name: str, slug: str, photos: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans: str[] } }[] }`
|
||||
- Returns: `200 { articles: { id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T36, article: { id: int, sku: str, name: str, slug: str, photos: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans: str[] } }[] }`
|
||||
#### Thumb image by hash — `GET /thumb/{fullHash}`
|
||||
- Params: `fullHash: str`
|
||||
- Returns: `200 avif`
|
||||
@@ -570,10 +577,10 @@ _none_
|
||||
- Returns: `200 str`
|
||||
#### List warehouses — `GET /warehouse`
|
||||
_none_
|
||||
- Returns: `200 { warehouses: T36[] }`
|
||||
- Returns: `200 { warehouses: T37[] }`
|
||||
#### Create warehouse — `POST /warehouse`
|
||||
- Params: `body: { name: str, sort?: int }`
|
||||
- Returns: `201 T34`
|
||||
- Returns: `201 T35`
|
||||
#### Reorder warehouses — `PUT /warehouse/order`
|
||||
- Params: `body: { warehouseIds: int[] }`
|
||||
- Returns: `200 { warehouseIds: int[] }`
|
||||
@@ -582,10 +589,10 @@ _none_
|
||||
- Returns: `204 void`
|
||||
#### Get warehouse by ID — `GET /warehouse/{id}`
|
||||
- Params: `id: int`
|
||||
- Returns: `200 T34`
|
||||
- Returns: `200 T35`
|
||||
#### Update warehouse (partial) — `PATCH /warehouse/{id}`
|
||||
- Params: `id: int, body: { name?: str, sort?: int }`
|
||||
- Returns: `200 T34`
|
||||
- Returns: `200 T35`
|
||||
#### Update warehouse — `PUT /warehouse/{id}`
|
||||
- Params: `id: int, body: { name?: str, sort?: int }`
|
||||
- Returns: `200 T34`
|
||||
- Returns: `200 T35`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Dash API Routes Overview
|
||||
|
||||
Overview of all 144 API endpoints across all modules.
|
||||
Overview of all 146 API endpoints across all modules.
|
||||
|
||||
### Notation
|
||||
|
||||
@@ -10,18 +10,18 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
||||
### Reusable types
|
||||
|
||||
- `T1` = `{ article: T2 }`
|
||||
- `T2` = `{ id: int, sku: str, name: str, slug: str, track_stock: bool, unitamount: num, weight: num, unit: obj, brand: obj, categoryIds: int[], photos: T17[], eans: str[], prices: T25[], suppliers: T9[] }`
|
||||
- `T2` = `{ id: int, sku: str, name: str, slug: str, track_stock: bool, unitamount: num, weight: num, unit: obj, brand: obj, categoryIds: int[], photos: T17[], eans: str[], prices: T26[], suppliers: T9[] }`
|
||||
- `T3` = `{ delivery: T4 }`
|
||||
- `T4` = `{ id: int, number: str, type: str, supplierId: int, externalNumber: str, date: str, createdAt: str, ledger: T29, lines: T18[], files: T8[] }`
|
||||
- `T4` = `{ id: int, number: str, type: str, supplierId: int, externalNumber: str, date: str, createdAt: str, ledger: T30, lines: T18[], files: T8[] }`
|
||||
- `T5` = `{ order: T7 }`
|
||||
- `T6` = `{ quote: T7 }`
|
||||
- `T7` = `{ id: int, number: str, type: str, entityId: int, date: str, createdAt: str, lines: T18[] }`
|
||||
- `T8` = `{ id: int, manifestId: int, fileId: int, sort: int, hash: str, mimetype: str, name: str, size: int, created: str, modified: str, thumbavif: str, thumbx: int, thumby: int, meta: obj }`
|
||||
- `T9` = `{ id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T32 }`
|
||||
- `T9` = `{ id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T33 }`
|
||||
- `T10` = `{ ledger: T11[] }`
|
||||
- `T11` = `{ id: int, manifestarticle_id: int, transaction_type: str, amount: num, transaction_text: str, hash_version: int, prev_hash: str, sku: str, created_at: str }`
|
||||
- `T12` = `{ id: int, entityId: int, firstName: str, name: str, street: str, streetNumber: str, zip: str, city: str, county: str, addressType: str }`
|
||||
- `T13` = `{ id: int, name: str, sort: int, exclusive: bool, values: T27[] }`
|
||||
- `T13` = `{ id: int, name: str, sort: int, exclusive: bool, values: T28[] }`
|
||||
- `T14` = `{ entity: T19 }`
|
||||
- `T15` = `{ printer: T20 }`
|
||||
- `T16` = `{ labeltemplate: T22 }`
|
||||
@@ -31,23 +31,24 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
||||
- `T20` = `{ id: int, company_id: int, address: str, type: str, model: str, serial: str, sort: int, desc: str }`
|
||||
- `T21` = `{ amount: num, net: num, taxrate: num, sku?: str, name?: str, pu?: num, rebate?: num, comment?: str }`
|
||||
- `T22` = `{ id: int, name: str, width: num, height: num, dpi: int, type: str, content: obj, thumb: str }`
|
||||
- `T23` = `{ article: T24 }`
|
||||
- `T24` = `{ id: int, categoryId: int, name: str, sku: str, track_stock: bool }`
|
||||
- `T25` = `{ minmultiplier: num, net: num, taxRate: num, customergroupId: int }`
|
||||
- `T26` = `{ id: int, entityId: int, contactType: str, contact: str }`
|
||||
- `T27` = `{ id: int, attributeId: int, value: str, sort: int }`
|
||||
- `T28` = `{ id: int, name: str, createdAt: str, updatedAt: str }`
|
||||
- `T29` = `{ totalPositions: int, completelyOnLedgerPositions: int }`
|
||||
- `T30` = `{ id: int, name: str, sort: int, exclusive: bool }`
|
||||
- `T31` = `{ warehouse: T33 }`
|
||||
- `T32` = `{ net: num, taxId: int, taxRate: num }`
|
||||
- `T33` = `{ id: int, name: str, sort: int }`
|
||||
- `T23` = `{ id: int, sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }`
|
||||
- `T24` = `{ article: T25 }`
|
||||
- `T25` = `{ id: int, categoryId: int, name: str, sku: str, track_stock: bool }`
|
||||
- `T26` = `{ minmultiplier: num, net: num, taxRate: num, customergroupId: int }`
|
||||
- `T27` = `{ id: int, entityId: int, contactType: str, contact: str }`
|
||||
- `T28` = `{ id: int, attributeId: int, value: str, sort: int }`
|
||||
- `T29` = `{ id: int, name: str, createdAt: str, updatedAt: str }`
|
||||
- `T30` = `{ totalPositions: int, completelyOnLedgerPositions: int }`
|
||||
- `T31` = `{ id: int, name: str, sort: int, exclusive: bool }`
|
||||
- `T32` = `{ warehouse: T34 }`
|
||||
- `T33` = `{ net: num, taxId: int, taxRate: num }`
|
||||
- `T34` = `{ id: int, name: str, sort: int }`
|
||||
|
||||
### Routes
|
||||
|
||||
#### Create article in category — `POST /article`
|
||||
- Params: `body: { categoryId: int, name: str, track_stock?: bool }`
|
||||
- Returns: `201 T23`
|
||||
- Returns: `201 T24`
|
||||
#### Delete article by SKU — `DELETE /article/{sku}`
|
||||
- Params: `sku: str, query: cascade?: bool`
|
||||
- Returns: `204 void`
|
||||
@@ -80,10 +81,10 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
||||
- Returns: `200 { children: { id: int, sku: str, name: str, parentsort: int, attributeValueId: int, attributeValue: str }[] }`
|
||||
#### Create and attach a new child article to a parent article — `POST /article/{sku}/children`
|
||||
- Params: `sku: str, body: { attributeValueId?: int, value?: str, name?: str }`
|
||||
- Returns: `201 T23`
|
||||
- Returns: `201 T24`
|
||||
#### Attach an existing article as a child to a parent article — `PUT /article/{sku}/children`
|
||||
- Params: `sku: str, body: { sku: str, attributeValueId?: int, value?: str, reparent?: bool }`
|
||||
- Returns: `200 { article: T24, children: obj[] }`
|
||||
- Returns: `200 { article: T25, children: obj[] }`
|
||||
#### Remove a child article from a parent article — `DELETE /article/{sku}/children/{childSku}`
|
||||
- Params: `sku: str, childSku: str, query: deleteArticle?: bool`
|
||||
- Returns: `200 { success: bool, deleted: bool }`
|
||||
@@ -107,7 +108,7 @@ Params: path values first, then `query:` and `body:` (`body?` = optional body).
|
||||
- Returns: `200 { options: obj[] }`
|
||||
#### Toggle parent mode for an article — `POST /article/{sku}/parent`
|
||||
- Params: `sku: str, body: { isParent: bool, attributeNameId?: int }`
|
||||
- Returns: `200 T23`
|
||||
- Returns: `200 T24`
|
||||
#### Replace POS prices by SKU — `PUT /article/{sku}/prices`
|
||||
- Params: `sku: str, body: { prices: { price: num, tax: num, minmultiplier?: num }[] }`
|
||||
- Returns: `200 T1`
|
||||
@@ -155,10 +156,10 @@ _none_
|
||||
- Returns: `200`
|
||||
#### List values for an attribute — `GET /attributename/{attributeId}/value`
|
||||
- Params: `attributeId: int`
|
||||
- Returns: `200 { values: T27[] }`
|
||||
- Returns: `200 { values: T28[] }`
|
||||
#### Create value for an attribute — `POST /attributename/{attributeId}/value`
|
||||
- Params: `attributeId: int, body: { value: str, sort?: int }`
|
||||
- Returns: `201 { attributevalue: T27 }`
|
||||
- Returns: `201 { attributevalue: T28 }`
|
||||
#### Reorder values of an attribute — `PUT /attributename/{attributeId}/value/order`
|
||||
- Params: `attributeId: int, body: { attributevalueIds: int[] }`
|
||||
- Returns: `200`
|
||||
@@ -173,7 +174,7 @@ _none_
|
||||
- Returns: `200`
|
||||
#### Update attribute value — `PATCH /attributevalue/{id}`
|
||||
- Params: `id: int, body: { value?: str, sort?: int }`
|
||||
- Returns: `200 { attributevalue: T27 }`
|
||||
- Returns: `200 { attributevalue: T28 }`
|
||||
#### Login with Google ID token — `POST /auth/login`
|
||||
- Params: `body: { idToken: str }`
|
||||
- Returns: `200 { message: str, user: { id: int, email: str, selectedCompanyId: int, picture: str } }`
|
||||
@@ -182,13 +183,19 @@ _none_
|
||||
- Returns: `200 { message: str }`
|
||||
#### List brands — `GET /brand`
|
||||
_none_
|
||||
- Returns: `200 { brands: { id: int, name: str, gsprpinfo: str, pics: { id: int, sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[] }[] }`
|
||||
- Returns: `200 { brands: { id: int, name: str, gsprpinfo: str, pics: T23[] }[] }`
|
||||
#### Upsert brand — `PUT /brand`
|
||||
- Params: `body: { name: str, gsprpinfo?: str }`
|
||||
- Returns: `200 { brand: { id: int, name: str, gsprpinfo: str, pics: { id: int, sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[] } }`
|
||||
- Returns: `200 { brand: { id: int, name: str, gsprpinfo: str, pics: T23[] } }`
|
||||
#### Delete brand — `DELETE /brand/{id}`
|
||||
- Params: `id: int`
|
||||
- Returns: `204 void`
|
||||
#### Delete brand image — `DELETE /brand/{id}/image`
|
||||
- Params: `id: int`
|
||||
- Returns: `200 { brand: { id: int, thumbW: int, thumbH: int, thumbHash: str, pics: T23[] } }`
|
||||
#### Add or replace brand image — `POST /brand/{id}/image`
|
||||
- Params: `id: int, image/avif`
|
||||
- Returns: `201 { brand: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: T23[] } }`
|
||||
#### Create category — `POST /category`
|
||||
- Params: `body: { parentId: int, name: str }`
|
||||
- Returns: `201 { category: { id: int, parentId: int, sort: int, name: str } }`
|
||||
@@ -251,7 +258,7 @@ _none_
|
||||
- Returns: `200 { customergroups: { id: int, name: str, sort: int, editable: bool }[] }`
|
||||
#### Create customer group — `POST /customergroup`
|
||||
- Params: `body: { name: str }`
|
||||
- Returns: `201 { customergroup: T33 }`
|
||||
- Returns: `201 { customergroup: T34 }`
|
||||
#### Reorder customer groups — `PUT /customergroup/order`
|
||||
- Params: `body: { customergroupIds: int[] }`
|
||||
- Returns: `200 { customergroupIds: int[] }`
|
||||
@@ -260,10 +267,10 @@ _none_
|
||||
- Returns: `204 void`
|
||||
#### Update customer group — `PATCH /customergroup/{id}`
|
||||
- Params: `id: int, body: { name: str }`
|
||||
- Returns: `200 { customergroup: T33 }`
|
||||
- Returns: `200 { customergroup: T34 }`
|
||||
#### List deliveries — `GET /delivery`
|
||||
_none_
|
||||
- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int, externalNumber: str, date: str, createdAt: str, ledger: T29 }[] }`
|
||||
- Returns: `200 { deliveries: { id: int, number: str, type: str, supplierId: int, externalNumber: str, date: str, createdAt: str, ledger: T30 }[] }`
|
||||
#### Create delivery — `POST /delivery`
|
||||
- Params: `body: { externalNumber: str, date: str, lines: T21[], supplierId?: int, files?: { mimetype: str, name: str, content: str, sort?: int, size?: int, hash?: str, created?: str, modified?: str, meta?: obj }[] }`
|
||||
- Returns: `201 T3`
|
||||
@@ -302,16 +309,16 @@ _none_
|
||||
- Returns: `200 { address: T12 }`
|
||||
#### List entity contacts — `GET /entity/{entityId}/contact`
|
||||
- Params: `entityId: int`
|
||||
- Returns: `200 { contacts: T26[] }`
|
||||
- Returns: `200 { contacts: T27[] }`
|
||||
#### Create entity contact — `POST /entity/{entityId}/contact`
|
||||
- Params: `entityId: int, body: { contactType: str, contact: str }`
|
||||
- Returns: `201 { contact: T26 }`
|
||||
- Returns: `201 { contact: T27 }`
|
||||
#### Delete entity contact — `DELETE /entity/{entityId}/contact/{id}`
|
||||
- Params: `entityId: int, id: int`
|
||||
- Returns: `204 void`
|
||||
#### Update entity contact — `PATCH /entity/{entityId}/contact/{id}`
|
||||
- Params: `entityId: int, id: int, body: { contactType?: str, contact?: str }`
|
||||
- Returns: `200 { contact: T26 }`
|
||||
- Returns: `200 { contact: T27 }`
|
||||
#### Delete entity — `DELETE /entity/{id}`
|
||||
- Params: `id: int`
|
||||
- Returns: `204 void`
|
||||
@@ -395,10 +402,10 @@ _none_
|
||||
- Returns: `200 T15`
|
||||
#### List property names — `GET /propertyname`
|
||||
_none_
|
||||
- Returns: `200 { propertynames: T30[] }`
|
||||
- Returns: `200 { propertynames: T31[] }`
|
||||
#### Create property name — `POST /propertyname`
|
||||
- Params: `body: { name: str, sort?: int, exclusive?: bool }`
|
||||
- Returns: `201 { propertyname: T30 }`
|
||||
- Returns: `201 { propertyname: T31 }`
|
||||
#### Reorder property names — `PUT /propertyname/order`
|
||||
- Params: `body: { propertynameIds: int[] }`
|
||||
- Returns: `200`
|
||||
@@ -407,7 +414,7 @@ _none_
|
||||
- Returns: `200`
|
||||
#### Update property name — `PATCH /propertyname/{id}`
|
||||
- Params: `id: int, body: { name?: str, sort?: int, exclusive?: bool }`
|
||||
- Returns: `200 { propertyname: T30 }`
|
||||
- Returns: `200 { propertyname: T31 }`
|
||||
#### List quotes — `GET /quote`
|
||||
_none_
|
||||
- Returns: `200 { quotes: { id: int, number: str, type: str, entityId: int, date: str, createdAt: str }[] }`
|
||||
@@ -428,22 +435,22 @@ _none_
|
||||
- Returns: `201 { manifest: { id: int, number: str, type: str, date: str, createdAt: str }, lines: obj[], ledger: T11[] }`
|
||||
#### List suppliers — `GET /supplier`
|
||||
_none_
|
||||
- Returns: `200 { suppliers: T28[] }`
|
||||
- Returns: `200 { suppliers: T29[] }`
|
||||
#### Create supplier — `POST /supplier`
|
||||
- Params: `body: { name: str }`
|
||||
- Returns: `201 { supplier: T28 }`
|
||||
- Returns: `201 { supplier: T29 }`
|
||||
#### Delete supplier — `DELETE /supplier/{id}`
|
||||
- Params: `id: int`
|
||||
- Returns: `204 void`
|
||||
#### Update supplier — `PATCH /supplier/{id}`
|
||||
- Params: `id: int, body: { name: str }`
|
||||
- Returns: `200 { supplier: T28 }`
|
||||
- Returns: `200 { supplier: T29 }`
|
||||
#### List supplier articles by SKUs — `GET /supplier/{id}/articles`
|
||||
- Params: `id: int, query: skus?: string`
|
||||
- Returns: `200 { articles: { id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T32, article: { id: int, sku: str, name: str, slug: str, photos: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans: str[] } }[] }`
|
||||
- Returns: `200 { articles: { id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T33, article: { id: int, sku: str, name: str, slug: str, photos: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans: str[] } }[] }`
|
||||
#### Query supplier articles by SKUs (bulk) — `POST /supplier/{id}/articles`
|
||||
- Params: `id: int, body?: { skus?: str[] }`
|
||||
- Returns: `200 { articles: { id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T32, article: { id: int, sku: str, name: str, slug: str, photos: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans: str[] } }[] }`
|
||||
- Returns: `200 { articles: { id: int, articleId: int, entityId: int, supplierName: str, sku: str, pu: num, stock: num, sort: int, priceId: int, price: T33, article: { id: int, sku: str, name: str, slug: str, photos: { sort: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str }[], eans: str[] } }[] }`
|
||||
#### Delete unit — `DELETE /unit`
|
||||
- Params: `query: si: str`
|
||||
- Returns: `204 void`
|
||||
@@ -458,10 +465,10 @@ _none_
|
||||
- Returns: `200 str`
|
||||
#### List warehouses — `GET /warehouse`
|
||||
_none_
|
||||
- Returns: `200 { warehouses: T33[] }`
|
||||
- Returns: `200 { warehouses: T34[] }`
|
||||
#### Create warehouse — `POST /warehouse`
|
||||
- Params: `body: { name: str, sort?: int }`
|
||||
- Returns: `201 T31`
|
||||
- Returns: `201 T32`
|
||||
#### Reorder warehouses — `PUT /warehouse/order`
|
||||
- Params: `body: { warehouseIds: int[] }`
|
||||
- Returns: `200 { warehouseIds: int[] }`
|
||||
@@ -470,13 +477,13 @@ _none_
|
||||
- Returns: `204 void`
|
||||
#### Get warehouse by ID — `GET /warehouse/{id}`
|
||||
- Params: `id: int`
|
||||
- Returns: `200 T31`
|
||||
- Returns: `200 T32`
|
||||
#### Update warehouse (partial) — `PATCH /warehouse/{id}`
|
||||
- Params: `id: int, body: { name?: str, sort?: int }`
|
||||
- Returns: `200 T31`
|
||||
- Returns: `200 T32`
|
||||
#### Update warehouse — `PUT /warehouse/{id}`
|
||||
- Params: `id: int, body: { name?: str, sort?: int }`
|
||||
- Returns: `200 T31`
|
||||
- Returns: `200 T32`
|
||||
### Binary & streaming routes (reachable only via `fetch()` in javascript_execute)
|
||||
|
||||
These routes are NOT in the table above because their responses are binary or long-lived streams, which the `dashback_request` tool cannot return usefully. They ARE reachable from inside `javascript_execute` with `fetch("/route")`, where you can decode the bytes, write them to the VFS and embed them in your reply:
|
||||
|
||||
51
docs/api/routes/brand/_id/image.delete.md
Normal file
51
docs/api/routes/brand/_id/image.delete.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# `DELETE /brand/{id}/image`
|
||||
|
||||
Protected. Requires a valid session cookie (`credentials: 'include'`).
|
||||
|
||||
Delete brand image
|
||||
|
||||
Removes the brand's image. Sets thumbW, thumbH, thumbHash back to null.
|
||||
|
||||
## Path parameters
|
||||
|
||||
| Param | Required | Type | Description |
|
||||
|-------|----------|------|-------------|
|
||||
| `id` | yes | integer | Brand id |
|
||||
|
||||
## Response `200`
|
||||
|
||||
Image removed
|
||||
|
||||
```json
|
||||
{
|
||||
"brand": {
|
||||
"id": 1,
|
||||
"thumbW": 1,
|
||||
"thumbH": 1,
|
||||
"thumbHash": "…",
|
||||
"pics": [
|
||||
{
|
||||
"id": 1,
|
||||
"sort": 1,
|
||||
"fullHash": "…",
|
||||
"thumbW": 1,
|
||||
"thumbH": 1,
|
||||
"thumbHash": "…"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Errors
|
||||
|
||||
| Status | Description |
|
||||
|--------|-------------|
|
||||
| 400 | No company selected or invalid id — `{"error":"…"}` |
|
||||
| 401 | Unauthorized — `{"error":"…"}` |
|
||||
| 403 | Not authorized — `{"error":"…"}` |
|
||||
| 404 | Brand or image not found — `{"error":"…"}` |
|
||||
|
||||
---
|
||||
|
||||
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._
|
||||
62
docs/api/routes/brand/_id/image.post.md
Normal file
62
docs/api/routes/brand/_id/image.post.md
Normal file
@@ -0,0 +1,62 @@
|
||||
# `POST /brand/{id}/image`
|
||||
|
||||
Protected. Requires a valid session cookie (`credentials: 'include'`).
|
||||
|
||||
Add or replace brand image
|
||||
|
||||
Uploads an image for the brand (AVIF, WebP, or octet-stream). Converted to AVIF full and thumbnail.
|
||||
Replaces any existing image for this brand.
|
||||
|
||||
|
||||
## Path parameters
|
||||
|
||||
| Param | Required | Type | Description |
|
||||
|-------|----------|------|-------------|
|
||||
| `id` | yes | integer | Brand id |
|
||||
|
||||
## Body
|
||||
|
||||
Raw binary (`image/avif`).
|
||||
|
||||
Raw binary (`image/webp`).
|
||||
|
||||
Raw binary (`application/octet-stream`).
|
||||
|
||||
## Response `201`
|
||||
|
||||
Image stored and linked
|
||||
|
||||
```json
|
||||
{
|
||||
"brand": {
|
||||
"id": 1,
|
||||
"fullHash": "…",
|
||||
"thumbW": 1,
|
||||
"thumbH": 1,
|
||||
"thumbHash": "…",
|
||||
"pics": [
|
||||
{
|
||||
"id": 1,
|
||||
"sort": 1,
|
||||
"fullHash": "…",
|
||||
"thumbW": 1,
|
||||
"thumbH": 1,
|
||||
"thumbHash": "…"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Errors
|
||||
|
||||
| Status | Description |
|
||||
|--------|-------------|
|
||||
| 400 | Missing body or invalid image — `{"error":"…"}` |
|
||||
| 401 | Unauthorized — `{"error":"…"}` |
|
||||
| 403 | Not authorized — `{"error":"…"}` |
|
||||
| 404 | Brand not found — `{"error":"…"}` |
|
||||
|
||||
---
|
||||
|
||||
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._
|
||||
@@ -243,6 +243,152 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /brand/{id}/image:
|
||||
* post:
|
||||
* tags: [Brand]
|
||||
* summary: Add or replace brand image
|
||||
* description: |
|
||||
* Uploads an image for the brand (AVIF, WebP, or octet-stream). Converted to AVIF full and thumbnail.
|
||||
* Replaces any existing image for this brand.
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Brand id
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* image/avif:
|
||||
* schema:
|
||||
* type: string
|
||||
* format: binary
|
||||
* image/webp:
|
||||
* schema:
|
||||
* type: string
|
||||
* format: binary
|
||||
* application/octet-stream:
|
||||
* schema:
|
||||
* type: string
|
||||
* format: binary
|
||||
* responses:
|
||||
* 201:
|
||||
* description: Image stored and linked
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* brand:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* fullHash:
|
||||
* type: string
|
||||
* thumbW:
|
||||
* type: integer
|
||||
* thumbH:
|
||||
* type: integer
|
||||
* thumbHash:
|
||||
* type: string
|
||||
* pics:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/BrandPic'
|
||||
* 400:
|
||||
* description: Missing body or invalid image
|
||||
* 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: Brand not found
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
* delete:
|
||||
* tags: [Brand]
|
||||
* summary: Delete brand image
|
||||
* description: Removes the brand's image. Sets thumbW, thumbH, thumbHash back to null.
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: integer
|
||||
* description: Brand id
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Image removed
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* brand:
|
||||
* type: object
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* thumbW:
|
||||
* type: integer
|
||||
* nullable: true
|
||||
* thumbH:
|
||||
* type: integer
|
||||
* nullable: true
|
||||
* thumbHash:
|
||||
* type: string
|
||||
* nullable: true
|
||||
* pics:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/BrandPic'
|
||||
* 400:
|
||||
* description: No company selected or invalid id
|
||||
* 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: Brand or image not found
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
app.post(
|
||||
`${basePath}/brand/:id/image`,
|
||||
express.raw({ type: ['image/avif', 'image/webp', 'application/octet-stream'], limit: AVIF_BODY_LIMIT }),
|
||||
|
||||
@@ -23,6 +23,7 @@ import { createAnalyzeImageTool } from '../tools/analyze-image.js';
|
||||
import { createWebSearchTool } from '../tools/web-search.js';
|
||||
import { createUrlGetTool } from '../tools/url-get.js';
|
||||
import { createPdfReadTool } from '../tools/pdf-read.js';
|
||||
import { createSearchArticlesTool } from '../tools/search-articles.js';
|
||||
import { resolveOpenRouterKey, resolveDefaultModel, RETIRED_MODELS, hasConfiguredOpenRouterKey } from '../tools/llm-key.js';
|
||||
|
||||
const KEEP_ALIVE_MS = 20_000;
|
||||
@@ -123,6 +124,7 @@ async function buildSystemPrompt(vfsRoot, googleAuthId) {
|
||||
'12. reset_vfs: Delete VFS files/artifacts. Preserves SKILL files.',
|
||||
'13. rm: Delete single VFS file (used to delete SKILL files or specific artifacts).',
|
||||
'14. apisuggestionsorissues: Report missing API endpoints, bugs, or issues for triage.',
|
||||
'15. search_articles: Search articles across name, brand, EAN, SKU, and supplier SKU. Returns window of full articles (default 3, max 20), offset, and total count.',
|
||||
'',
|
||||
'VIRTUAL FILESYSTEM:',
|
||||
'- Persistent per-company VFS. Paths are root-relative forward-slash (e.g. "labels/sheet1.png").',
|
||||
@@ -138,15 +140,24 @@ async function buildSystemPrompt(vfsRoot, googleAuthId) {
|
||||
'',
|
||||
'IMAGES:',
|
||||
'- Evaluate images via analyze_image; report model findings.',
|
||||
'- Flow: search_images("query") → analyze_image({ paths: [...], prompt: "…" }) → upload via dashback_request.',
|
||||
'- Flow: search_images("query") → analyze_image({ paths: [...], prompt: "…" }) → upload via fetch in javascript_execute.',
|
||||
'- `image/` is READ-ONLY database storage. Write generated images elsewhere (e.g. "images/…").',
|
||||
'',
|
||||
'OPERATING GUIDELINES:',
|
||||
'- GROSS vs NET PRICES: User prices are almost always GROSS (incl. VAT); API requires NET. Formula: `net = gross / (1 + taxRate / 100)`. Compute in javascript_execute with high precision (4–6 decimals) to prevent rounding error.',
|
||||
'- DISPLAYING GENERATED IMAGES: Inline markdown images supported. Embed written VFS image paths: ``. Other files (PDF, JSON, CSV) do not render inline; provide download links.',
|
||||
'- LABEL TEMPLATES (/labeltemplate): Must use Dashback JSON schema `{ "objects": [ ... ] }`. Do NOT use ZPL.',
|
||||
'- Format output with markdown tables, bullet points, or bold key-value pairs.',
|
||||
...(routesDoc ? ['', 'DASHBACK API ROUTES:', routesDoc] : []),
|
||||
'- Always Format output with markdown and emoji.',
|
||||
...(routesDoc ? [
|
||||
'',
|
||||
'DASHBACK API ROUTES:',
|
||||
'Binary image upload routes (use via fetch() in javascript_execute with image/avif buffer body):',
|
||||
'- POST /article/{sku}/image (Params: sku: str, body: image/avif -> 201 { image: { picId: int, sort: int, full: { w, h, size }, thumb: { w, h }, hash: str, thumbHash: str } })',
|
||||
'- POST /category/{id}/image (Params: id: int, body: image/avif -> 201 { category: { id: int, thumbW: int, thumbH: int, thumbHash: str } })',
|
||||
'- POST /brand/{id}/image (Params: id: int, body: image/avif -> 201 { brand: { id: int, fullHash: str, thumbW: int, thumbH: int, thumbHash: str, pics: [...] } })',
|
||||
'',
|
||||
routesDoc,
|
||||
] : []),
|
||||
].join('\n');
|
||||
|
||||
const sections = [];
|
||||
@@ -632,6 +643,7 @@ export class ConversationManager {
|
||||
createPdfReadTool({ googleAuthId }),
|
||||
createResetVfsTool({ googleAuthId }),
|
||||
createApiSuggestionsOrIssuesTool({ googleAuthId, companyId: this.companyId }),
|
||||
createSearchArticlesTool({ googleAuthId, companyId: this.companyId }),
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
180
src/tools/search-articles.js
Normal file
180
src/tools/search-articles.js
Normal file
@@ -0,0 +1,180 @@
|
||||
import { defineTool, ToolError } from 'libllmorbiter';
|
||||
import { getStore, getProvider } from '../db/store.js';
|
||||
|
||||
const DEFAULT_LIMIT = 3;
|
||||
const MAX_LIMIT = 20;
|
||||
|
||||
function parseWords(input) {
|
||||
if (typeof input === 'string') {
|
||||
return input.toLowerCase().trim().split(/\s+/).filter(Boolean);
|
||||
}
|
||||
if (Array.isArray(input)) {
|
||||
return input.map((w) => String(w).toLowerCase().trim()).filter(Boolean);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the search_articles tool.
|
||||
* Searches articles across name, brand, EAN, SKU, and supplier SKU.
|
||||
* Returns a window of full articles (default 3, max 20), the offset, and the total count.
|
||||
* @param {{ googleAuthId: number, companyId?: number }} ctx
|
||||
*/
|
||||
export function createSearchArticlesTool({ googleAuthId, companyId }) {
|
||||
return defineTool({
|
||||
name: 'search_articles',
|
||||
description:
|
||||
'Text search articles by name, brand, EAN, SKU, or supplier SKU. ' +
|
||||
`Returns window of full articles (default ${DEFAULT_LIMIT}, max ${MAX_LIMIT}), offset, and total count. Ordered alphabetically by name.`,
|
||||
strict: false,
|
||||
parameters: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
properties: {
|
||||
searchquery: {
|
||||
type: 'string',
|
||||
description: 'Words that must all match across name, brand, EAN, SKU, or supplier SKU (AND logic, order-independent).',
|
||||
},
|
||||
excludewords: {
|
||||
type: 'string',
|
||||
description: 'Words that if all match exclude the article (AND logic, order-independent).',
|
||||
},
|
||||
offset: {
|
||||
type: 'integer',
|
||||
description: 'Pagination offset. Default 0.',
|
||||
},
|
||||
limit: {
|
||||
type: 'integer',
|
||||
description: `Result window size (1–${MAX_LIMIT}). Default ${DEFAULT_LIMIT}.`,
|
||||
},
|
||||
},
|
||||
},
|
||||
invoke: async ({ searchquery = '', excludewords = '', offset = 0, limit = DEFAULT_LIMIT } = {}) => {
|
||||
const store = await getStore();
|
||||
const provider = await getProvider();
|
||||
|
||||
let targetCompanyId = companyId;
|
||||
if (!targetCompanyId) {
|
||||
const gaRes = await provider.query(
|
||||
'SELECT selected_company AS selectedCompanyId FROM google_auth WHERE id = @googleAuthId',
|
||||
{ googleAuthId }
|
||||
);
|
||||
targetCompanyId = gaRes.rows[0]?.selectedCompanyId;
|
||||
}
|
||||
if (!targetCompanyId) {
|
||||
throw new ToolError('No company selected');
|
||||
}
|
||||
|
||||
const coRes = await provider.query(
|
||||
'SELECT default_language_id AS languageId FROM company WHERE id = @companyId',
|
||||
{ companyId: targetCompanyId }
|
||||
);
|
||||
const languageId = coRes.rows[0]?.languageId || 1;
|
||||
|
||||
const [artRes, eanRes, supRes] = await Promise.all([
|
||||
provider.query(
|
||||
`SELECT a.id, a.sku, at.name, b.name AS brandName
|
||||
FROM article a
|
||||
LEFT JOIN articletext at ON at.article_id = a.id AND at.language_id = @languageId
|
||||
LEFT JOIN brand b ON b.id = a.brand_id
|
||||
WHERE a.company_id = @companyId`,
|
||||
{ companyId: targetCompanyId, languageId }
|
||||
),
|
||||
provider.query(
|
||||
`SELECT ae.article_id AS articleId, ae.ean
|
||||
FROM articleean ae
|
||||
INNER JOIN article a ON a.id = ae.article_id
|
||||
WHERE a.company_id = @companyId`,
|
||||
{ companyId: targetCompanyId }
|
||||
),
|
||||
provider.query(
|
||||
`SELECT asup.article_id AS articleId, asup.sku AS supplierSku
|
||||
FROM articlesupplier asup
|
||||
INNER JOIN article a ON a.id = asup.article_id
|
||||
WHERE a.company_id = @companyId`,
|
||||
{ companyId: targetCompanyId }
|
||||
),
|
||||
]);
|
||||
|
||||
const eansMap = new Map();
|
||||
for (const row of eanRes.rows) {
|
||||
if (!row.ean) continue;
|
||||
let list = eansMap.get(row.articleId);
|
||||
if (!list) {
|
||||
list = [];
|
||||
eansMap.set(row.articleId, list);
|
||||
}
|
||||
list.push(String(row.ean));
|
||||
}
|
||||
|
||||
const supplierSkusMap = new Map();
|
||||
for (const row of supRes.rows) {
|
||||
if (!row.supplierSku) continue;
|
||||
let list = supplierSkusMap.get(row.articleId);
|
||||
if (!list) {
|
||||
list = [];
|
||||
supplierSkusMap.set(row.articleId, list);
|
||||
}
|
||||
list.push(String(row.supplierSku));
|
||||
}
|
||||
|
||||
const searchableArticles = artRes.rows.map((row) => {
|
||||
const eans = eansMap.get(row.id) || [];
|
||||
const supplierSkus = supplierSkusMap.get(row.id) || [];
|
||||
const name = row.name || '';
|
||||
const brand = row.brandName || '';
|
||||
const sku = row.sku || '';
|
||||
const searchableText = `${name} ${brand} ${sku} ${eans.join(' ')} ${supplierSkus.join(' ')}`.toLowerCase();
|
||||
return {
|
||||
id: row.id,
|
||||
sku: row.sku,
|
||||
name,
|
||||
searchableText,
|
||||
};
|
||||
});
|
||||
|
||||
const searchWords = parseWords(searchquery);
|
||||
const excludeWords = parseWords(excludewords);
|
||||
|
||||
const filtered = searchableArticles.filter((art) => {
|
||||
if (searchWords.length > 0) {
|
||||
const matchesAll = searchWords.every((word) => art.searchableText.includes(word));
|
||||
if (!matchesAll) return false;
|
||||
}
|
||||
if (excludeWords.length > 0) {
|
||||
const matchesAllExclude = excludeWords.every((word) => art.searchableText.includes(word));
|
||||
if (matchesAllExclude) return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
filtered.sort((a, b) => (a.name || '').localeCompare(b.name || '', 'de', { sensitivity: 'base' }));
|
||||
|
||||
const total = filtered.length;
|
||||
const startOffset = Math.max(0, parseInt(offset, 10) || 0);
|
||||
const pageSize = Math.min(Math.max(1, parseInt(limit, 10) || DEFAULT_LIMIT), MAX_LIMIT);
|
||||
const windowSlice = filtered.slice(startOffset, startOffset + pageSize);
|
||||
|
||||
const fullArticles = (
|
||||
await Promise.all(
|
||||
windowSlice.map(async (item) => {
|
||||
try {
|
||||
const { article } = await store.article.getBySku(googleAuthId, item.sku);
|
||||
return article;
|
||||
} catch (err) {
|
||||
console.warn(`[search_articles] could not load full article for sku ${item.sku}:`, err.message);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
)
|
||||
).filter(Boolean);
|
||||
|
||||
return {
|
||||
total,
|
||||
offset: startOffset,
|
||||
limit: pageSize,
|
||||
articles: fullArticles,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user