Skip to content

SettingsService

@blobs/sdk v0.1.0


@blobs/sdk / services / SettingsService

Defined in: services/SettingsService.ts:33

Handles per-user settings as a key/value document. Provides whole-object access (getSettings/updateSettings/resetSettings) plus convenience setters for common preferences like the selected theme. Settings are cached for 10 minutes per user.

Theme responsibilities boundary:

  • ThemesService handles theme entities (CRUD: create/read/update/delete/publish).
  • SettingsService.setThemePreference writes the user’s selected theme — it’s a preference, not a theme entity edit.

Example

const sdk = createSDK({ networks: [...] });
const res = await sdk.settings.getSettings();

Constructors

Constructor

new SettingsService(context): SettingsService

Defined in: services/SettingsService.ts:41

Constructs a SettingsService bound to the given context.

Parameters

context

BlobsContext

Shared BlobsContext providing transport and cache.

Returns

SettingsService

Methods

getSettings()

getSettings(options?): Promise<Response<UserSettings>>

Defined in: services/SettingsService.ts:71

Returns the current user’s full settings document, served from cache when available.

Parameters

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<UserSettings>>

A Response containing the UserSettings document.

Throws

ApiError when the user is not authenticated.


updateSettings()

updateSettings(settings, options?): Promise<Response<UserSettings>>

Defined in: services/SettingsService.ts:104

Partially updates the current user’s settings, merging the provided fields with existing values. Invalidates the settings cache.

Parameters

settings

Partial<SettingsData>

Partial SettingsData to merge into the existing document.

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<UserSettings>>

A Response containing the updated UserSettings document.

Throws

ValidationError when the input contains rejected fields.

Example

await sdk.settings.updateSettings({ language: 'en-US' });

resetSettings()

resetSettings(options?): Promise<Response<UserSettings>>

Defined in: services/SettingsService.ts:129

Resets the current user’s settings document to platform defaults and invalidates the cache.

Parameters

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<UserSettings>>

A Response containing the freshly defaulted UserSettings document.


setThemePreference()

setThemePreference(themeId, options?): Promise<Response<UserSettings>>

Defined in: services/SettingsService.ts:153

Sets the current user’s selected theme preference. This writes a per-user preference, not the theme entity itself — use ThemesService to manage theme entities.

Parameters

themeId

string

The Theme ID to mark as the user’s preferred theme.

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<UserSettings>>

A Response containing the updated UserSettings document.


updateTheme()

updateTheme(themeId, options?): Promise<Response<UserSettings>>

Defined in: services/SettingsService.ts:179

Sets the current user’s selected theme preference.

Parameters

themeId

string

The Theme ID to mark as the user’s preferred theme.

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<UserSettings>>

A Response containing the updated UserSettings document.

Deprecated

Use setThemePreference instead. The old name implied editing a theme entity, but this method writes a user preference. Kept as an alias for backwards compatibility.