feat(companysetting): add writeonly column and mask values for GUI
This commit is contained in:
@@ -16,23 +16,24 @@ Returns a single company setting by key for the user's selected company.
|
||||
| `key` | `string` | The setting key. |
|
||||
| `[options]` | `object` | Optional options. |
|
||||
| `[options.frontendOnly]` | `boolean` | Only return the setting if it is frontend-visible. |
|
||||
| `[options.maskWriteonly]` | `boolean` | Mask writeonly settings as '***'. Defaults to `frontendOnly` (usergui gets '***', backend gets full value). |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{key: string, value: string, frontend: boolean}|undefined>` — The setting, or `undefined` if not found.
|
||||
`Promise<{key: string, value: string, frontend: boolean, writeonly: boolean}|undefined>` — The setting, or `undefined` if not found.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const setting = await store.companysetting.get(42, 'theme');
|
||||
// => { key, value, frontend }
|
||||
const setting = await store.companysetting.get(42, 'ui.theme');
|
||||
// => { key, value, frontend, writeonly }
|
||||
```
|
||||
|
||||
## `companysetting.list`
|
||||
|
||||
*Source: `src/store/companysetting/list.js`*
|
||||
|
||||
Lists the settings of the user's selected company, optionally only frontend-visible ones.
|
||||
Lists the settings of the user's selected company, optionally only frontend-visible ones. Write-only settings (such as `keys.tavily`, `keys.openrouter`) have their value masked with `'***'` by default for usergui presentation.
|
||||
|
||||
**Parameters**
|
||||
|
||||
@@ -41,23 +42,24 @@ Lists the settings of the user's selected company, optionally only frontend-visi
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `[options]` | `object` | Optional options. |
|
||||
| `[options.frontendOnly]` | `boolean` | Only return frontend-visible settings. |
|
||||
| `[options.maskWriteonly]` | `boolean` | Whether to mask writeonly settings with '***'. Defaults to `true`. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<Array<{key: string, value: string, frontend: boolean}>>` — The settings.
|
||||
`Promise<Array<{key: string, value: string, frontend: boolean, writeonly: boolean}>>` — The settings.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const settings = await store.companysetting.list(42, { frontendOnly: true });
|
||||
// => [{ key, value, frontend }]
|
||||
// => [{ key, value, frontend, writeonly }]
|
||||
```
|
||||
|
||||
## `companysetting.set`
|
||||
|
||||
*Source: `src/store/companysetting/set.js`*
|
||||
|
||||
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`.
|
||||
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`. Keys in the write-only set (`keys.tavily`, `keys.openrouter`) are stored with `writeonly = 1`; when retrieved by the GUI the value is returned as `"***"`. The backend always receives the real value.
|
||||
|
||||
**Parameters**
|
||||
|
||||
@@ -68,10 +70,11 @@ Sets (upserts) a company setting by key for the user's selected company. Only a
|
||||
| `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. |
|
||||
| `[input.writeonly]` | `boolean` | Whether the setting is write-only. Defaults to true for `keys.tavily` and `keys.openrouter`, false otherwise. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{key: string, value: string, frontend: boolean}>` — The upserted setting.
|
||||
`Promise<{key: string, value: string, frontend: boolean, writeonly: boolean}>` — The upserted setting.
|
||||
|
||||
**Throws**
|
||||
|
||||
@@ -81,5 +84,5 @@ Sets (upserts) a company setting by key for the user's selected company. Only a
|
||||
|
||||
```js
|
||||
const setting = await store.companysetting.set(42, { key: 'ui.theme', value: 'dark' });
|
||||
// => { key, value, frontend }
|
||||
// => { key, value, frontend, writeonly }
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user