ThemesService
@blobs/sdk / services / ThemesService
Defined in: services/ThemesService.ts:26
Handles CRUD operations and version publishing for UI themes. Themes are cached for 30 minutes per ID and as a whole list. The publish method finalizes a draft theme into a versioned release that other users may consume.
Note: theme selection (which theme the current user prefers) is handled separately by
SettingsService.setThemePreference; this service deals only with theme entities.
Example
const sdk = createSDK({ networks: [...] });const res = await sdk.themes.create({ name: 'Dark Mode', tokens: {...} });Constructors
Constructor
new ThemesService(
context):ThemesService
Defined in: services/ThemesService.ts:34
Constructs a ThemesService bound to the given context.
Parameters
context
Shared BlobsContext providing transport and cache.
Returns
ThemesService
Methods
create()
Defined in: services/ThemesService.ts:65
Creates a new theme and invalidates the theme list cache.
Parameters
input
Theme fields to create (name, tokens, metadata).
options?
Optional network/tenant scoping options.
Returns
A Response containing the created Theme with server-assigned id and timestamps.
Throws
ValidationError when input is rejected.
getById()
Defined in: services/ThemesService.ts:90
Fetches a theme by ID, served from cache when available.
Parameters
id
string
The theme identifier.
useCache?
boolean = true
When true (default), returns a cached value if present; pass false to force a network fetch.
options?
Optional network/tenant scoping options.
Returns
A Response containing the Theme.
Throws
NotFoundError when no theme with the given ID exists.
list()
Defined in: services/ThemesService.ts:118
Lists all themes owned by or visible to the current user.
Parameters
useCache?
boolean = true
When true (default), returns a cached value if present; pass false to force a network fetch.
options?
Optional network/tenant scoping options.
Returns
A Response containing an array of Theme records.
update()
Defined in: services/ThemesService.ts:149
Updates a theme and invalidates both its individual cache entry and the list cache.
Parameters
id
string
The theme identifier.
input
Partial theme fields to update.
options?
Optional network/tenant scoping options.
Returns
A Response containing the updated Theme.
Throws
NotFoundError when no theme with the given ID exists.
Throws
PermissionError when the user lacks write access.
delete()
delete(
id,options?):Promise<Response<void>>
Defined in: services/ThemesService.ts:175
Deletes a theme and clears its cache entries.
Parameters
id
string
The theme identifier.
options?
Optional network/tenant scoping options.
Returns
Promise<Response<void>>
A Response with no payload on success.
Throws
NotFoundError when no theme with the given ID exists.
Throws
PermissionError when the user lacks delete access.
publish()
Defined in: services/ThemesService.ts:201
Publishes a theme as a versioned release, making it available for consumption by other users.
Parameters
id
string
The theme identifier to publish.
input
Publish metadata (version, changelog, visibility).
options?
Optional network/tenant scoping options.
Returns
A Response containing the published Theme with updated version metadata.
Throws
PermissionError when the user lacks publish rights on the theme.
unpublish()
unpublish(
publishedThemeId,options?):Promise<Response<void>>
Defined in: services/ThemesService.ts:225
Unpublishes a previously published theme snapshot. The original draft is left intact.
Parameters
publishedThemeId
string
id of the published-snapshot row
(the value returned by a prior publish() call, NOT the draft id).
options?
Returns
Promise<Response<void>>
listPublic()
Defined in: services/ThemesService.ts:248
Lists publicly available themes published on the current network.
Parameters
options?
Optional network/tenant scoping options.