Used to check for browser translation.
用于检测浏览器翻译。
ブラウザの翻訳を検出する
API Reference

Data & Operations


These mutations allow you to manage the data and operational state of your Blocklet Server and its blocklets. This includes creating backups, restoring data, migrating application structures, and clearing caches. For read-only data operations, see the Data & Operations Queries section.


backupBlocklet#

Initiates a backup process for a specified blocklet. You can back up to connected DID Spaces or the local disk.

Parameters

Name

Type

Description

input.appDid

string

The DID of the blocklet to back up.

input.to

enum

The backup destination. Can be 'spaces' or 'disk'.

Example

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient('https://node.url');

try {
const response = await client.backupBlocklet({
input: {
appDid: 'z8iZqj...j9kP',
to: 'spaces',
},
});
if (response.code === 'ok') {
console.log('Backup process started successfully.');
}
} catch (error) {
console.error('Error starting backup:', error);
}

The backupBlocklet mutation returns a GeneralResponse object. A code of ok indicates that the backup job was successfully queued.

Example Response

{
"backupBlocklet": {
"code": "ok"
}
}


abortBlockletBackup#

Aborts a backup process that is currently in progress.

Parameters

Name

Type

Description

input.appPid

string

The PID (process identifier/DID) of the blocklet whose backup should be aborted.

Example

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient('https://node.url');

try {
const response = await client.abortBlockletBackup({
input: {
appPid: 'z8iZqj...j9kP',
},
});
if (response.code === 'ok') {
console.log('Backup abortion initiated.');
}
} catch (error) {
console.error('Error aborting backup:', error);
}

Example Response

{
"abortBlockletBackup": {
"code": "ok"
}
}


restoreBlocklet#

Restores a blocklet from a previously created backup.

Parameters

Name

Type

Description

input.from

enum

The source of the backup. Can be 'spaces' or 'disk'.

input.appPid

string

The DID of the blocklet to restore.

input.endpoint

string

The endpoint URL of the backup source (e.g., space URL).

input.appDid

string

The application DID from the backup.

input.delegation

string

Delegation information for accessing the backup.

input.wallet

object

Wallet object for authentication if required.

Example

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient('https://node.url');

try {
const response = await client.restoreBlocklet({
input: {
from: 'spaces',
appPid: 'z8iZqj...j9kP',
endpoint: 'https://myspace.did.space',
appDid: 'zApp...',
delegation: '...',
wallet: {
/* wallet object */
},
},
});
if (response.code === 'ok') {
console.log('Restore process started.');
}
} catch (error) {
console.error('Error restoring blocklet:', error);
}

Example Response

{
"restoreBlocklet": {
"code": "ok"
}
}


migrateApplicationToStructV2#

Migrates an application from an older data structure to the V2 structure, which is required for features like backups.

Parameters

Name

Type

Description

input.did

string

The DID of the application to migrate.

input.appSk

string

The secret key of the application.

Example

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient('https://node.url');

try {
const response = await client.migrateApplicationToStructV2({
input: {
did: 'z8iZqj...j9kP',
appSk: 'sk_...',
},
});
if (response.code === 'ok') {
console.log('Migration successful.');
}
} catch (error) {
console.error('Error migrating application:', error);
}

Example Response

{
"migrateApplicationToStructV2": {
"code": "ok"
}
}


clearCache#

Clears cached items from the node's storage. You can specify a pattern to clear specific caches.

Parameters

Name

Type

Description

input.teamDid

string

The DID of the team/blocklet context for which to clear the cache.

input.pattern

string

Optional. A glob pattern to match cache keys for removal. If omitted, all cache for the teamDid might be cleared.

Example

import BlockletServerClient from '@blocklet/server-js';

const client = new BlockletServerClient('https://node.url');

try {
const response = await client.clearCache({
input: {
teamDid: 'z8iZqj...j9kP',
pattern: 'user:*',
},
});
console.log('Cache cleared:', response.removed);
} catch (error) {
console.error('Error clearing cache:', error);
}

Example Response

{
"clearCache": {
"code": "ok",
"removed": ["cache:user:z1...", "cache:user:z2..."]
}
}

Now that you know how to manage data operations, you may want to explore how to manage blocklet publishing and release cycles. Proceed to the Publishing & Projects section to learn more.