Files
dashlibstorage/API.labeltemplate.md
2026-09-27 22:01:56 +02:00

4.2 KiB
Raw Blame History

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 — label editor objects).
[input.thumb] Buffer|null Optional pre-rendered 50×50 1-bit PNG thumbnail.
[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 name, content or dimensions are missing, or dpi/type is invalid.

Example

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

const template = await store.labeltemplate.getById(googleAuthId, 1);
// => { id: 1, company_id: 1, name: 'Product Label', width: 448, height: 200, dpi: 203, type: 'zpl', ... }

labeltemplate.list

Source: src/store/labeltemplate/list.js

Lists all label templates 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, name: string, width: number, height: number, dpi: number, type: string, content: object, thumb: Buffer|null}>>

Example

const templates = await store.labeltemplate.list(42);
// => [{ id: 1, company_id: 1, name: 'Product Label', ... }]

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 (all fields optional).
[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.
[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, name is empty, or dpi/type is invalid.