92 lines
3.1 KiB
Markdown
92 lines
3.1 KiB
Markdown
# companysetting
|
|
|
|
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
|
|
|
## `companysetting.get`
|
|
|
|
*Source: `src/store/companysetting/get.js`*
|
|
|
|
Returns a single 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. |
|
|
| `[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). |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`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, '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. Write-only settings (such as `keys.tavily`, `keys.openrouter`) have their value masked with `'***'` by default for usergui presentation.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `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`. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`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, writeonly }]
|
|
```
|
|
|
|
## `companysetting.set`
|
|
|
|
*Source: `src/store/companysetting/set.js`*
|
|
|
|
Sets (upserts) a company setting by key for the user's selected company.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `input` | `object` | The setting input. |
|
|
| `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`, `keys.openrouter`, and `keys.serper`, false otherwise. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<{key: string, value: string, frontend: boolean, writeonly: boolean}>` — The upserted setting.
|
|
|
|
**Throws**
|
|
|
|
`Error` — If the input is invalid.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const setting = await store.companysetting.set(42, { key: 'ui.theme', value: 'dark' });
|
|
// => { key, value, frontend, writeonly }
|
|
```
|