u
This commit is contained in:
165
API.printer.md
Normal file
165
API.printer.md
Normal file
@@ -0,0 +1,165 @@
|
||||
# printer
|
||||
|
||||
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
||||
|
||||
## `printer.create`
|
||||
|
||||
*Source: `src/store/printer/create.js`*
|
||||
|
||||
Creates a new printer for the user's selected company.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `input` | `object` | Printer input. |
|
||||
| `input.address` | `string` | Printer address (network IP/host/path). |
|
||||
| `input.type` | `string` | Printer type ("esc/pos" or "zpl"). |
|
||||
| `[input.model]` | `string` | Optional printer model name. |
|
||||
| `[input.serial]` | `string` | Optional printer serial number. |
|
||||
| `[input.sort]` | `number` | Optional sort order (auto-increments if omitted). |
|
||||
| `[input.desc]` | `string` | Optional description. |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{id: number, company_id: number, address: string, type: string, model: string|null, serial: string|null, sort: number, desc: string|null}>`
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If address is missing, type is invalid, or sort is invalid.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const printer = await store.printer.create(googleAuthId, {
|
||||
address: '192.168.1.200',
|
||||
type: 'esc/pos',
|
||||
model: 'TM-T88VI',
|
||||
desc: 'Bar receipt printer',
|
||||
});
|
||||
```
|
||||
|
||||
## `printer.delete`
|
||||
|
||||
*Source: `src/store/printer/delete.js`*
|
||||
|
||||
Deletes a printer for the user's selected company.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `id` | `number` | The printer ID to delete. |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<void>`
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If printer is not found.
|
||||
|
||||
## `printer.getById`
|
||||
|
||||
*Source: `src/store/printer/getById.js`*
|
||||
|
||||
Retrieves a printer 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 printer ID. |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{id: number, company_id: number, address: string, type: string, model: string|null, serial: string|null, sort: number, desc: string|null}|undefined>`
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const printer = await store.printer.getById(googleAuthId, 1);
|
||||
// => { id: 1, company_id: 1, address: '192.168.1.100', type: 'esc/pos', ... }
|
||||
```
|
||||
|
||||
## `printer.list`
|
||||
|
||||
*Source: `src/store/printer/list.js`*
|
||||
|
||||
Lists all printers for the user's selected company.
|
||||
|
||||
**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, address: string, type: string, model: string|null, serial: string|null, sort: number, desc: string|null}>>`
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const printers = await store.printer.list(42);
|
||||
// => [{ id: 1, company_id: 1, address: '192.168.1.100', type: 'esc/pos', ... }]
|
||||
```
|
||||
|
||||
## `printer.order`
|
||||
|
||||
*Source: `src/store/printer/order.js`*
|
||||
|
||||
Reorders the printers of the user's selected company.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `input` | `object` | The reorder input. |
|
||||
| `input.printerIds` | `Array<number>` | The printer ids in their new order. |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{printerIds: Array<number>}>` — The applied order.
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If the order is invalid.
|
||||
|
||||
## `printer.update`
|
||||
|
||||
*Source: `src/store/printer/update.js`*
|
||||
|
||||
Updates a printer for the user's selected company.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `id` | `number` | The printer ID to update. |
|
||||
| `input` | `object` | Update payload. |
|
||||
| `[input.address]` | `string` | The printer address. |
|
||||
| `[input.type]` | `string` | The printer type ("esc/pos" or "zpl"). |
|
||||
| `[input.model]` | `string|null` | The printer model. |
|
||||
| `[input.serial]` | `string|null` | The printer serial. |
|
||||
| `[input.sort]` | `number` | The sort order. |
|
||||
| `[input.desc]` | `string|null` | The description. |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{id: number, company_id: number, address: string, type: string, model: string|null, serial: string|null, sort: number, desc: string|null}>`
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If printer not found, address is empty, type is invalid, or sort is invalid.
|
||||
Reference in New Issue
Block a user