feat(numbers): add number sequences store; restrict companysetting keys
- Add `numbers` store module with `list` and `update` methods backed by the `numbers` table (prefix, padding, next) per company. - Add sql queries LIST_BY_COMPANY, GET_BY_COMPANY_AND_ID, UPDATE_... - Regenerate and wire API docs for `numbers`. companysetting: - Remove the `delete` endpoint (settings are now upsert/read only). - Restrict `set` to a fixed allow-list of keys: ui.theme, keys.tavily, keys.openrouter, labelprinter.addr, labelprinter.type. - Drop DELETE_BY_COMPANY_AND_KEY sql and the delete store file. Docs: update README, API.md, API.companysetting.md, API.numbers.md.
This commit is contained in:
58
API.numbers.md
Normal file
58
API.numbers.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# numbers
|
||||
|
||||
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
||||
|
||||
## `numbers.list`
|
||||
|
||||
*Source: `src/store/numbers/list.js`*
|
||||
|
||||
Lists the number sequences of the user's selected company.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<Array<{id: number, type: string, prefix: string, padding: number, next: number}>>` — The number sequences.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const numbers = await store.numbers.list(42);
|
||||
// => [{ id, type, prefix, padding, next }]
|
||||
```
|
||||
|
||||
## `numbers.update`
|
||||
|
||||
*Source: `src/store/numbers/update.js`*
|
||||
|
||||
Updates the sequence settings of a number for the user's selected company. Only the provided fields are changed (all optional). `prefix` is trimmed and must be at most 50 characters. `padding` and `next` must be finite numbers greater than or equal to 0 and 1 respectively. If no field is provided, the row is returned unchanged.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `id` | `number` | The id of the number sequence to update. |
|
||||
| `input` | `object` | The update input. |
|
||||
| `[input.prefix]` | `string` | The new prefix. |
|
||||
| `[input.padding]` | `number` | The new padding length. |
|
||||
| `[input.next]` | `number` | The new next value. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{id: number, type: string, prefix: string, padding: number, next: number}>` — The updated number sequence.
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If the number is not found or a field is invalid.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const number = await store.numbers.update(42, 3, { prefix: 'A-', padding: 4, next: 100 });
|
||||
// => { id, type, prefix, padding, next }
|
||||
```
|
||||
Reference in New Issue
Block a user