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
This commit is contained in:
seb
2026-08-07 06:23:17 +02:00
parent 396389457f
commit aefd97a171
127 changed files with 3956 additions and 1684 deletions

View File

@@ -8,9 +8,29 @@ This document is auto-generated from the JSDoc comments in `src/store` by runnin
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**
```js
const fn = create(pool);
const entity = await fn(42, { customergroupId: 5, name: 'Doe', firstName: 'John' });
const entity = await store.entity.create(42, { customergroupId: 5, name: 'Doe', firstName: 'John' });
// => { id, customergroupId, firstName, name, number, createdAt, updatedAt }
```
@@ -18,22 +38,54 @@ const entity = await fn(42, { customergroupId: 5, name: 'Doe', firstName: 'John'
*Source: `src/store/entity/delete.js`*
Deletes an entity by its id within a company.
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**
```js
const fn = del(pool);
await fn(42, 5);
await store.entity.delete(42, 5);
```
## `entity.getById`
*Source: `src/store/entity/getById.js`*
Returns a single entity by its id within a company.
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**
```js
const fn = getById(pool);
const entity = await fn(42, 5);
const entity = await store.entity.getById(42, 5);
// => { id, customergroupId, firstName, name, number, createdAt, updatedAt }
```
@@ -41,13 +93,31 @@ const entity = await fn(42, 5);
*Source: `src/store/entity/isNumberFree.js`*
Returns whether a customer number is free within the company. Pass `excludeEntityId` when editing so the entity's own number counts as free.
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**
```js
const fn = isNumberFree(pool);
const free = await fn(42, 'C-100');
const free = await store.entity.isNumberFree(42, 'C-100');
// => true
const freeOnEdit = await fn(42, 'C-100', { excludeEntityId: 5 });
const freeOnEdit = await store.entity.isNumberFree(42, 'C-100', { excludeEntityId: 5 });
// => true
```
@@ -55,11 +125,29 @@ const freeOnEdit = await fn(42, 'C-100', { excludeEntityId: 5 });
*Source: `src/store/entity/list.js`*
Lists the entities (customers) of a company, optionally filtered by customer group or restricted to the 'customer' role.
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**
```js
const fn = list(pool);
const entities = await fn(42, { customergroupId: 5 });
const entities = await store.entity.list(42, { customergroupId: 5 });
// => [{ id, customergroupId, firstName, name, number, createdAt, updatedAt }]
```
@@ -67,11 +155,22 @@ const entities = await fn(42, { customergroupId: 5 });
*Source: `src/store/entity/peekNextNumber.js`*
Returns the next customer number that would be allocated for the company (`numbers` type `entity`) without consuming it.
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**
```js
const fn = peekNextNumber(pool);
const number = await fn(42);
const number = await store.entity.peekNextNumber(42);
// => '1'
```
@@ -81,8 +180,28 @@ const number = await fn(42);
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**
```js
const fn = update(pool);
const entity = await fn(42, 5, { name: 'Doe', firstName: 'Jane', number: 'C-42' });
const entity = await store.entity.update(42, 5, { name: 'Doe', firstName: 'Jane', number: 'C-42' });
// => { id, customergroupId, firstName, name, number, createdAt, updatedAt }
```