Files
dashlibstorage/API.entity.md
seb aefd97a171 Rewrite store JSDoc, split quote/order into modules, and generate typed API docs
- Rewrite JSDoc across all store methods to document the actual async
  methods (real params, returns, throws) instead of the internal wrappers
- Split quote/order into individual module files backed by shared
  manifestDoc helpers; remove the createStore factory and thin wrappers
- Deduplicate manifest line helpers into src/store/manifestLines.js
- Extend generate-api-doc.js to render parameter/return/throws types and
  emit per-namespace API.<module>.md files with an API.md index
- Regenerate all API docs
2026-08-07 06:23:17 +02:00

5.6 KiB

entity

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

entity.create

Source: src/store/entity/create.js

Creates a new entity (customer) in a customer group, recording history. Optional number; if omitted, allocates via getnextnumberwithprefixandpadding (type entity).

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
input object The entity creation input.
input.customergroupId number The id of the customer group.
input.name string The entity name.
[input.firstName] string The entity first name.
[input.number] string Optional explicit customer number.

Returns

Promise<{id: number, customergroupId: number, firstName: string|null, name: string, number: string, createdAt: string, updatedAt: string}> — The created entity.

Throws

Error — If the name is empty.

Example

const entity = await store.entity.create(42, { customergroupId: 5, name: 'Doe', firstName: 'John' });
// => { id, customergroupId, firstName, name, number, createdAt, updatedAt }

entity.delete

Source: src/store/entity/delete.js

Deletes an entity by its id within the user's selected company.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
id number The id of the entity to delete.

Returns

Promise<void>

Throws

Error — If the entity is not found.

Example

await store.entity.delete(42, 5);

entity.getById

Source: src/store/entity/getById.js

Returns a single entity by its id within the user's selected company.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
id number The id of the entity.

Returns

Promise<{id: number, customergroupId: number, firstName: string|null, name: string, number: string, createdAt: string, updatedAt: string}> — The entity.

Throws

Error — If the entity is not found.

Example

const entity = await store.entity.getById(42, 5);
// => { id, customergroupId, firstName, name, number, createdAt, updatedAt }

entity.isNumberFree

Source: src/store/entity/isNumberFree.js

Returns whether a customer number is free within the user's selected company. Pass excludeEntityId when editing so the entity's own number counts as free.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
number string The customer number to check.
[options] object Optional options.
[options.excludeEntityId] number An entity id to exclude from the check.

Returns

Promise<boolean> — Whether the number is free.

Throws

Error — If the number is empty.

Example

const free = await store.entity.isNumberFree(42, 'C-100');
// => true
const freeOnEdit = await store.entity.isNumberFree(42, 'C-100', { excludeEntityId: 5 });
// => true

entity.list

Source: src/store/entity/list.js

Lists the entities (customers) of the user's selected company, optionally filtered by customer group or restricted to the 'customer' role.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
[options] object Optional options.
[options.customergroupId] number Filter by customer group id.
[options.role] string Restrict to 'customer' role if set.

Returns

Promise<Array<{id: number, customergroupId: number, firstName: string|null, name: string, number: string, createdAt: string, updatedAt: string}>> — The entities.

Throws

Error — If the role is invalid.

Example

const entities = await store.entity.list(42, { customergroupId: 5 });
// => [{ id, customergroupId, firstName, name, number, createdAt, updatedAt }]

entity.peekNextNumber

Source: src/store/entity/peekNextNumber.js

Returns the next customer number that would be allocated for the user's selected company (numbers type entity) without consuming it.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.

Returns

Promise<string> — The next entity number.

Example

const number = await store.entity.peekNextNumber(42);
// => '1'

entity.update

Source: src/store/entity/update.js

Updates name, first name, and/or customer number of an entity, recording history. Optional number sets the customer number explicitly (does not auto-allocate).

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
id number The id of the entity to update.
patch object The update patch.
[patch.name] string The new entity name.
[patch.firstName] string The new first name.
[patch.number] string The new customer number.

Returns

Promise<{id: number, customergroupId: number, firstName: string|null, name: string, number: string, createdAt: string, updatedAt: string}> — The updated entity.

Throws

Error — If no valid field is provided or the entity is not found.

Example

const entity = await store.entity.update(42, 5, { name: 'Doe', firstName: 'Jane', number: 'C-42' });
// => { id, customergroupId, firstName, name, number, createdAt, updatedAt }