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:
seb
2026-08-08 09:03:51 +02:00
parent aefd97a171
commit f302cda39e
12 changed files with 272 additions and 79 deletions

View File

@@ -2,33 +2,6 @@
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
## `companysetting.delete`
*Source: `src/store/companysetting/delete.js`*
Deletes a company setting by key for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `key` | `string` | The setting key. |
**Returns**
`Promise<void>`
**Throws**
`Error` — If the setting is not found.
**Example**
```js
await store.companysetting.delete(42, 'theme');
```
## `companysetting.get`
*Source: `src/store/companysetting/get.js`*
@@ -84,7 +57,7 @@ const settings = await store.companysetting.list(42, { frontendOnly: true });
*Source: `src/store/companysetting/set.js`*
Sets (upserts) a company setting by key for the user's selected company.
Sets (upserts) a company setting by key for the user's selected company. Only a fixed allow-list of keys can be set: `ui.theme`, `keys.tavily`, `keys.openrouter`, `labelprinter.addr`, `labelprinter.type`.
**Parameters**
@@ -92,7 +65,7 @@ Sets (upserts) a company setting by key for the user's selected company.
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `input` | `object` | The setting input. |
| `input.key` | `string` | The setting key. |
| `input.key` | `string` | The setting key (must be in the allow-list). |
| `input.value` | `string` | The setting value. |
| `[input.frontend]` | `boolean` | Whether the setting is frontend-visible. |
@@ -107,6 +80,6 @@ Sets (upserts) a company setting by key for the user's selected company.
**Example**
```js
const setting = await store.companysetting.set(42, { key: 'theme', value: 'dark', frontend: true });
const setting = await store.companysetting.set(42, { key: 'ui.theme', value: 'dark' });
// => { key, value, frontend }
```