Skip to content

ThemesService

@blobs/sdk v0.1.0


@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

BlobsContext

Shared BlobsContext providing transport and cache.

Returns

ThemesService

Methods

create()

create(input, options?): Promise<Response<Theme>>

Defined in: services/ThemesService.ts:65

Creates a new theme and invalidates the theme list cache.

Parameters

input

CreateThemeInput

Theme fields to create (name, tokens, metadata).

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<Theme>>

A Response containing the created Theme with server-assigned id and timestamps.

Throws

ValidationError when input is rejected.


getById()

getById(id, useCache?, options?): Promise<Response<Theme>>

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?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<Theme>>

A Response containing the Theme.

Throws

NotFoundError when no theme with the given ID exists.


list()

list(useCache?, options?): Promise<Response<Theme[]>>

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?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<Theme[]>>

A Response containing an array of Theme records.


update()

update(id, input, options?): Promise<Response<Theme>>

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

UpdateThemeInput

Partial theme fields to update.

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<Theme>>

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?

MultiNetworkOptions

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()

publish(id, input, options?): Promise<Response<Theme>>

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

PublishThemeInput

Publish metadata (version, changelog, visibility).

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<Theme>>

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?

MultiNetworkOptions

Returns

Promise<Response<void>>


listPublic()

listPublic(options?): Promise<Response<Theme[]>>

Defined in: services/ThemesService.ts:248

Lists publicly available themes published on the current network.

Parameters

options?

MultiNetworkOptions

Optional network/tenant scoping options.

Returns

Promise<Response<Theme[]>>

A Response containing an array of public Theme records.