Skip to content

Commit db3f61e

Browse files
committed
feat: Enhance global settings with type support
- Updated global settings schema to include a 'type' field for each setting, allowing for 'string', 'number', or 'boolean' types. - Modified the GlobalSettingsService to handle typed values, including validation and conversion methods. - Adjusted plugin settings to specify types for each configuration option. - Updated migration files to add the new 'type' column to the globalSettings table. - Enhanced validation logic in the global settings route to ensure values match their declared types. - Updated tests to cover new type functionality for global settings.
1 parent 88b1e49 commit db3f61e

File tree

17 files changed

+845
-27
lines changed

17 files changed

+845
-27
lines changed

services/backend/PLUGINS.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ class MyAwesomePlugin implements Plugin {
366366
settings: [
367367
{
368368
key: 'myAwesomePlugin.features.enableSuperFeature',
369-
defaultValue: 'true',
369+
defaultValue: true,
370+
type: 'boolean',
370371
description: 'Enables the super feature of this plugin.',
371372
encrypted: false,
372373
required: false,
@@ -375,17 +376,28 @@ class MyAwesomePlugin implements Plugin {
375376
{
376377
key: 'myAwesomePlugin.credentials.externalApiKey',
377378
defaultValue: '',
379+
type: 'string',
378380
description: 'API key for an external service used by this plugin.',
379381
encrypted: true, // Sensitive value, will be encrypted
380382
required: true,
381383
groupId: 'my_awesome_plugin_group',
382384
},
385+
{
386+
key: 'myAwesomePlugin.performance.maxRetries',
387+
defaultValue: 5,
388+
type: 'number',
389+
description: 'Maximum number of retries for API calls.',
390+
encrypted: false,
391+
required: false,
392+
groupId: 'my_awesome_plugin_group',
393+
},
383394
{
384395
// Example of a setting not belonging to a new custom group
385396
// It might appear in a default group or ungrouped in the UI,
386397
// or you can assign it to an existing core group ID if appropriate.
387398
key: 'myAwesomePlugin.performance.cacheDurationSeconds',
388-
defaultValue: '3600',
399+
defaultValue: 3600,
400+
type: 'number',
389401
description: 'Cache duration in seconds for plugin data.',
390402
encrypted: false,
391403
required: false,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `globalSettings` ADD `type` text DEFAULT 'string' NOT NULL;

0 commit comments

Comments
 (0)