This commit is contained in:
seb
2026-10-30 18:09:33 +01:00
parent 745d0d0077
commit c7d1b1a5d2
8 changed files with 164 additions and 14 deletions

View File

@@ -61,6 +61,52 @@ Deletes a printer agent of the user's selected company.
await store.printeragent.delete(42, 5);
```
## `printeragent.findByPairingpin`
*Source: `src/store/printeragent/findByPairingpin.js`*
Finds a printer agent by its pairing pin.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `pairingpin` | `string` | The pairing pin to search for. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, companyId: number, name: string, token: string|null, pairingpin: string|null, pairedAt: string|null, clientserial: string|null, clientmodel: string|null, clientstate: string|null, agentversion: string|null, lastseenAt: string|null, updatedAt: string, sort: number}|null>` — The printer agent, or null if not found.
**Example**
```js
const agent = await store.printeragent.findByPairingpin('123456');
```
## `printeragent.findByToken`
*Source: `src/store/printeragent/findByToken.js`*
Finds a printer agent by its authentication token.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `token` | `string` | The auth token to search for. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, companyId: number, name: string, token: string|null, pairingpin: string|null, pairedAt: string|null, clientserial: string|null, clientmodel: string|null, clientstate: string|null, agentversion: string|null, lastseenAt: string|null, updatedAt: string, sort: number}|null>` — The printer agent, or null if not found.
**Example**
```js
const agent = await store.printeragent.findByToken('abc...');
```
## `printeragent.list`
*Source: `src/store/printeragent/list.js`*
@@ -85,6 +131,47 @@ const agents = await store.printeragent.list(42);
// => [{ id, companyId, name, token, pairingpin, pairedAt, clientserial, clientmodel, clientstate, agentversion, lastseenAt, updatedAt, sort }]
```
## `printeragent.pair`
*Source: `src/store/printeragent/pair.js`*
Completes device pairing for a printer agent.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `id` | `number` | The printer agent id. |
| `input` | `object` | |
| `input.token` | `string` | Auth token for the paired device. |
| `[input.clientserial]` | `string` | Device serial identifier. |
| `[input.clientmodel]` | `string` | Device model name. |
| `[input.agentversion]` | `string` | Device agent software version. |
| `[input.pairedAt]` | `string` | Timestamp when paired. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, companyId: number, name: string, token: string|null, pairingpin: string|null, pairedAt: string|null, clientserial: string|null, clientmodel: string|null, clientstate: string|null, agentversion: string|null, lastseenAt: string|null, updatedAt: string, sort: number}>`
## `printeragent.touchLastseen`
*Source: `src/store/printeragent/touchLastseen.js`*
Updates lastseen_at (and optionally agentversion) for a printer agent.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `id` | `number` | The printer agent id. |
| `[agentversion]` | `string|null` | Optional agent version to update. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number}>`
## `printeragent.update`
*Source: `src/store/printeragent/update.js`*
@@ -115,3 +202,21 @@ Updates name and/or sort of a printer agent of the user's selected company.
```js
const agent = await store.printeragent.update(42, { id: 5, name: 'Kitchen printer', sort: 1 });
```
## `printeragent.updateState`
*Source: `src/store/printeragent/updateState.js`*
Updates the client state of a printer agent.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `id` | `number` | The printer agent id. |
| `clientstate` | `string|null` | The state payload/string. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, companyId: number, name: string, token: string|null, pairingpin: string|null, pairedAt: string|null, clientserial: string|null, clientmodel: string|null, clientstate: string|null, agentversion: string|null, lastseenAt: string|null, updatedAt: string, sort: number}>`