- 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
87 lines
2.0 KiB
Markdown
87 lines
2.0 KiB
Markdown
# unit
|
|
|
|
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
|
|
|
## `unit.delete`
|
|
|
|
*Source: `src/store/unit/delete.js`*
|
|
|
|
Deletes a unit for the user's selected company by its SI code.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `si` | `string` | The SI code of the unit to delete. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<void>`
|
|
|
|
**Throws**
|
|
|
|
`Error` — If the unit is not found.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
await store.unit.delete(42, 'l');
|
|
```
|
|
|
|
## `unit.list`
|
|
|
|
*Source: `src/store/unit/list.js`*
|
|
|
|
Lists the units available for the user's selected company.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<Array<{id: number, si: string, basesi: string, basesifactor: number, symbol: string, name: string}>>` — The units.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const units = await store.unit.list(42);
|
|
// => [{ id, si, basesi, basesifactor, symbol, name }]
|
|
```
|
|
|
|
## `unit.upsert`
|
|
|
|
*Source: `src/store/unit/upsert.js`*
|
|
|
|
Creates or updates a unit for the user's selected company, keyed by its SI code.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `input` | `object` | The unit input. |
|
|
| `input.si` | `string` | The SI code. |
|
|
| `input.basesi` | `string` | The base SI code. |
|
|
| `input.basesifactor` | `number` | The base SI factor (must be > 0). |
|
|
| `input.symbol` | `string` | The unit symbol. |
|
|
| `input.name` | `string` | The unit name. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<{id: number, si: string, basesi: string, basesifactor: number, symbol: string, name: string}>` — The upserted unit.
|
|
|
|
**Throws**
|
|
|
|
`Error` — If the unit is invalid.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const unit = await store.unit.upsert(42, { si: 'l', basesi: 'm3', basesifactor: 0.001, symbol: 'L', name: 'Liter' });
|
|
// => { id, si, basesi, basesifactor, symbol, name }
|
|
```
|