Files
dashlibstorage/API.printeragent.md
2026-10-30 18:09:33 +01:00

7.3 KiB

printeragent

This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.

printeragent.create

Source: src/store/printeragent/create.js

Creates an unpaired printer agent for the user's selected company. The agent registers itself later using the pairing pin.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
input object The printer agent input.
input.name string The display name.
input.pairingpin string The pairing pin the agent uses to register.
[input.sort] number Display order (integer, ascending). Default 0.
[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}> — The created printer agent.

Throws

Error — 'Invalid printeragent' if name or pairingpin is missing/blank or sort is not an integer.

Example

const agent = await store.printeragent.create(42, { name: 'Bar printer', pairingpin: '123456' });

printeragent.delete

Source: src/store/printeragent/delete.js

Deletes a printer agent of the user's selected company.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
id number The printer agent id.
[tx] object Optional transaction to run within.

Returns

Promise<void>

Throws

Error — 'Printeragent not found' if the id is unknown in the company.

Example

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

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

const agent = await store.printeragent.findByToken('abc...');

printeragent.list

Source: src/store/printeragent/list.js

Lists the printer agents of 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, 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}>> — The printer agents.

Example

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`
[tx] object Optional transaction to run within.

Returns

Promise<{id: number}>

printeragent.update

Source: src/store/printeragent/update.js

Updates name and/or sort of a printer agent of the user's selected company.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
input object The update input.
input.id number The printer agent id.
[input.name] string The new display name.
[input.sort] number The new display order (integer).
[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}> — The updated printer agent.

Throws

Error — 'Invalid printeragent' if name is blank, sort is not an integer, or neither is given; 'Printeragent not found' if id is unknown in the company.

Example

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`
[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}>