Files
dashlibstorage/API.labeltemplate.md
2026-09-28 06:50:10 +02:00

145 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# labeltemplate
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
## `labeltemplate.create`
*Source: `src/store/labeltemplate/create.js`*
Creates a new label template for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `input` | `object` | Label template input. |
| `input.name` | `string` | Template name. |
| `input.width` | `number` | Canvas width in pixels. |
| `input.height` | `number` | Canvas height in pixels. |
| `input.dpi` | `number` | Printer DPI (203 or 300). |
| `input.type` | `string` | Template type ("zpl"). |
| `input.content` | `object` | Template content (JSON). |
| `[input.thumb]` | `Buffer|null` | 50×50 1-bit PNG thumbnail buffer. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, company_id: number, name: string, width: number, height: number, dpi: number, type: string, content: object, thumb: Buffer|null}>`
**Throws**
`Error` — If required fields are missing or invalid.
**Example**
```js
const template = await store.labeltemplate.create(googleAuthId, {
name: 'Product Label',
width: 448,
height: 200,
dpi: 203,
type: 'zpl',
content: { objects: [] },
});
```
## `labeltemplate.delete`
*Source: `src/store/labeltemplate/delete.js`*
Deletes a label template for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `id` | `number` | The label template ID to delete. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<void>`
**Throws**
`Error` — If template is not found.
## `labeltemplate.getById`
*Source: `src/store/labeltemplate/getById.js`*
Retrieves a label template by its ID for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `id` | `number` | The label template ID. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, company_id: number, name: string, width: number, height: number, dpi: number, type: string, content: object, thumb: Buffer|null}|undefined>`
**Example**
```js
const template = await store.labeltemplate.getById(googleAuthId, 1);
```
## `labeltemplate.list`
*Source: `src/store/labeltemplate/list.js`*
Lists all label templates for the user's selected company. `content.objects` is omitted to reduce payload size.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<Array<{id: number, company_id: number, name: string, width: number, height: number, dpi: number, type: string, content: object, thumb: Buffer|null}>>`
**Example**
```js
const templates = await store.labeltemplate.list(42);
```
## `labeltemplate.update`
*Source: `src/store/labeltemplate/update.js`*
Updates a label template for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `id` | `number` | The label template ID to update. |
| `input` | `object` | Update payload. |
| `[input.name]` | `string` | Template name. |
| `[input.width]` | `number` | Canvas width in pixels. |
| `[input.height]` | `number` | Canvas height in pixels. |
| `[input.dpi]` | `number` | Printer DPI (203 or 300). |
| `[input.type]` | `string` | Template type ("zpl"). |
| `[input.content]` | `object` | Template content (JSON). |
| `[input.thumb]` | `Buffer|null` | 50×50 1-bit PNG thumbnail buffer. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, company_id: number, name: string, width: number, height: number, dpi: number, type: string, content: object, thumb: Buffer|null}>`
**Throws**
`Error` — If template not found or input invalid.