This section details the mutations available for managing the entire lifecycle of your blocklet projects, from creation and release management to connecting with blocklet stores and publishing your work. These mutations enable programmatic control over how your projects are developed, versioned, and distributed.
For fetching project-related data, please see the Publishing & Projects Queries documentation.
Project Management
These mutations handle the creation, modification, and deletion of your development projects.
createProject
Creates a new project for a specified blocklet component, setting it up for future releases and publishing.
Parameters
- input
RequestCreateProjectInput(required) — An object containing the project details.- did
string(required) — The DID of the blocklet that owns the project. - type
PublishType(required) — The type of project, either 'resource' or 'pack'. - blockletDid
string(required) — The DID of the blocklet being published. - blockletTitle
string(required) — The title of the blocklet. - componentDid
string— The DID of the component associated with the project. - tenantScope
string— The scope of the tenant.
- did
Example
Create Project
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { project } = await client.mutation.createProject({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
type: 'resource',
blockletDid: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
blockletTitle: 'My New Blocklet Project',
componentDid: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
},
});
console.log('Project created:', project.id);
} catch (error) {
console.error('Error creating project:', error);
}Response
- ResponseProject
object- code
StatusCode— Indicates the result of the operation. - project
Project— The newly created project object.
- code
updateProject
Updates the details of an existing project, such as its title, description, or introduction.
Parameters
- input
RequestUpdateProjectInput(required) — An object containing the project details to update.- did
string(required) — The DID of the blocklet that owns the project. - projectId
string(required) — The ID of the project to update. - blockletTitle
string— The new title for the blocklet. - blockletDescription
string— The new description for the blocklet. - blockletIntroduction
string— The new introduction for the blocklet. - autoUpload
boolean— Whether to automatically upload resources. - possibleSameStore
boolean— Whether it's possible to publish to the same store. - blockletSupport
string— URL for blocklet support. - blockletCommunity
string— URL for the blocklet community. - blockletHomepage
string— URL for the blocklet's homepage.
- did
Example
Update Project
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { project } = await client.mutation.updateProject({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
projectId: 'project_12345',
blockletTitle: 'My Updated Blocklet Project',
blockletDescription: 'An updated description for my project.',
},
});
console.log('Project updated:', project.id);
} catch (error) {
console.error('Error updating project:', error);
}Response
- ResponseProject
object- code
StatusCode— Indicates the result of the operation. - project
Project— The updated project object.
- code
deleteProject
Permanently deletes a project. This action cannot be undone.
Parameters
- input
RequestProjectInput(required) — An object containing the project identifier.- did
string(required) — The DID of the blocklet that owns the project. - projectId
string(required) — The ID of the project to delete.
- did
Example
Delete Project
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.deleteProject({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
projectId: 'project_12345',
},
});
console.log('Project deleted successfully.');
} catch (error) {
console.error('Error deleting project:', error);
}Response
- GeneralResponse
object- code
StatusCode— Indicates the result of the operation.
- code
Release Management
These mutations are used to create and manage releases for your projects.
createRelease
Creates a new release for a project, capturing a specific version of the blocklet with associated metadata.
Parameters
- input
RequestCreateReleaseInput(required) — An object containing the release details.- did
string(required) — The DID of the blocklet that owns the project. - projectId
string(required) — The ID of the project for this release. - blockletDid
string(required) — The DID of the blocklet version for this release. - blockletVersion
string(required) — The version number of the blocklet. - note
string— Release notes or a summary of changes. - blockletTitle
string— The title for this release. - blockletDescription
string— The description for this release. - blockletScreenshots
string[]— An array of URLs for screenshots.
- did
Example
Create Release
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { release } = await client.mutation.createRelease({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
projectId: 'project_12345',
blockletDid: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
blockletVersion: '1.0.0',
note: 'Initial release with core features.',
},
});
console.log('Release created:', release.id);
} catch (error) {
console.error('Error creating release:', error);
}Response
- ResponseRelease
object- code
StatusCode— Indicates the result of the operation. - release
Release— The newly created release object.
- code
deleteRelease
Permanently deletes a release from a project.
Parameters
- input
RequestReleaseInput(required) — An object containing the release identifier.- did
string(required) — The DID of the blocklet that owns the project. - projectId
string(required) — The ID of the project containing the release. - releaseId
string(required) — The ID of the release to delete.
- did
Example
Delete Release
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.deleteRelease({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
projectId: 'project_12345',
releaseId: 'release_67890',
},
});
console.log('Release deleted successfully.');
} catch (error) {
console.error('Error deleting release:', error);
}Response
- GeneralResponse
object- code
StatusCode— Indicates the result of the operation.
- code
Resource Management
This mutation is used for managing resources associated with a project release.
updateSelectedResources
Updates the list of resources selected for a specific release of a component within a project.
Parameters
- input
RequestUpdateSelectedResourcesInput(required) — An object containing the resource selection details.- did
string(required) — The DID of the blocklet that owns the project. - projectId
string(required) — The ID of the project. - releaseId
string(required) — The ID of the release. - componentDid
string(required) — The DID of the component whose resources are being updated. - resources
string[](required) — An array of resource identifiers to be selected.
- did
Example
Update Selected Resources
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.updateSelectedResources({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
projectId: 'project_12345',
releaseId: 'release_67890',
componentDid: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
resources: ['resource_a', 'resource_b'],
},
});
console.log('Selected resources updated.');
} catch (error) {
console.error('Error updating resources:', error);
}Response
- GeneralResponse
object- code
StatusCode— Indicates the result of the operation.
- code
Store & Endpoint Connectivity
These mutations manage the connection between your projects and various publishing destinations like Blocklet Stores and endpoints.
connectToStore
Initiates a connection between a project and a Blocklet Store, returning a URL for completing the authorization process.
Parameters
- input
RequestConnectToStoreInput(required) — An object containing the store connection details.- did
string(required) — The DID of the blocklet that owns the project. - storeId
string(required) — The unique identifier of the Blocklet Store. - storeUrl
string(required) — The URL of the Blocklet Store. - storeName
string(required) — The name of the Blocklet Store. - projectId
string(required) — The ID of the project to connect.
- did
Example
Connect to Store
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { url } = await client.mutation.connectToStore({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
projectId: 'project_12345',
storeId: 'store_abc',
storeUrl: 'https://store.example.com',
storeName: 'Example Store',
},
});
console.log('Connect to store URL:', url);
} catch (error) {
console.error('Error connecting to store:', error);
}Response
- ResponseConnectToStore
object- code
StatusCode— Indicates the result of the operation. - url
string— The authorization URL to complete the connection.
- code
publishToStore
Publishes a specific release of a project to a connected Blocklet Store.
Parameters
- input
RequestPublishToStoreInput(required) — An object containing the publishing details.- did
string(required) — The DID of the blocklet that owns the project. - projectId
string(required) — The ID of the project being published. - releaseId
string(required) — The ID of the release to publish. - type
string(required) — The type of content being published (e.g., 'resource'). - storeId
string(required) — The ID of the target Blocklet Store.
- did
Example
Publish to Store
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { url } = await client.mutation.publishToStore({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
projectId: 'project_12345',
releaseId: 'release_67890',
storeId: 'store_abc',
type: 'resource',
},
});
console.log('Publish to store URL:', url);
} catch (error) {
console.error('Error publishing to store:', error);
}Response
- ResponsePublishToStore
object- code
StatusCode— Indicates the result of the operation. - url
string— A URL to track the status of the publishing process.
- code
disconnectFromStore
Disconnects a project from a Blocklet Store, removing the association.
Parameters
- input
RequestDisconnectFromStoreInput(required) — An object containing the details for disconnecting from the store.- did
string(required) — The DID of the blocklet that owns the project. - storeId
string(required) — The ID of the store to disconnect from. - projectId
string(required) — The ID of the project to disconnect. - storeScope
string— The scope of the store connection.
- did
Example
Disconnect from Store
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.disconnectFromStore({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
projectId: 'project_12345',
storeId: 'store_abc',
},
});
console.log('Successfully disconnected from the store.');
} catch (error) {
console.error('Error disconnecting from store:', error);
}Response
- ResponseDisconnectFromStore
object- code
StatusCode— Indicates the result of the operation.
- code
connectToAigne
Connects a blocklet to an AIGNE service, which provides AI capabilities.
Parameters
- input
RequestConnectToAigneInput(required) — An object containing AIGNE connection details.- did
string(required) — The DID of the blocklet to connect. - baseUrl
string(required) — The base URL of the AIGNE service. - provider
string(required) — The AI provider (e.g., 'openai'). - model
string(required) — The specific model to use (e.g., 'gpt-4').
- did
Example
Connect to AIGNE
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { url } = await client.mutation.connectToAigne({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
baseUrl: 'https://aigne.example.com',
provider: 'openai',
model: 'gpt-4-turbo',
},
});
console.log('Connect to AIGNE URL:', url);
} catch (error) {
console.error('Error connecting to AIGNE:', error);
}Response
- ResponseConnectToEndpoint
object- code
StatusCode— Indicates the result of the operation. - url
string— The authorization URL to complete the connection.
- code
disconnectToAigne
Disconnects a blocklet from an AIGNE service.
Parameters
- input
RequestDisconnectToAigneInput(required) — An object containing details for disconnecting from AIGNE.- did
string(required) — The DID of the blocklet to disconnect. - url
string(required) — The URL of the AIGNE service to disconnect from. - key
string(required) — The API key used for the connection.
- did
Example
Disconnect from AIGNE
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.disconnectToAigne({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
url: 'https://aigne.example.com',
key: 'your-api-key',
},
});
console.log('Successfully disconnected from AIGNE.');
} catch (error) {
console.error('Error disconnecting from AIGNE:', error);
}Response
- GeneralResponse
object- code
StatusCode— Indicates the result of the operation.
- code
verifyAigneConnection
Verifies the connection to an AIGNE service for a blocklet.
Parameters
- input
RequestVerifyAigneConnectionInput(required) — An object containing the blocklet DID.- did
string(required) — The DID of the blocklet whose AIGNE connection is to be verified.
- did
Example
Verify AIGNE Connection
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.verifyAigneConnection({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
},
});
console.log('AIGNE connection verified successfully.');
} catch (error) {
console.error('Error verifying AIGNE connection:', error);
}Response
- GeneralResponse
object- code
StatusCode— Indicates the result of the operation.
- code
connectToEndpoint
Establishes a connection between a project and a generic publishing endpoint.
Parameters
- input
RequestConnectToEndpointInput(required) — Details for connecting to the endpoint.- did
string(required) — The DID of the blocklet owning the project. - endpointId
string(required) — The ID of the endpoint to connect to. - projectId
string(required) — The ID of the project.
- did
Example
Connect to Endpoint
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { url } = await client.mutation.connectToEndpoint({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
endpointId: 'endpoint_xyz',
projectId: 'project_12345',
},
});
console.log('Connect to endpoint URL:', url);
} catch (error) {
console.error('Error connecting to endpoint:', error);
}Response
- ResponseConnectToEndpoint
object- code
StatusCode— Indicates the result of the operation. - url
string— The authorization URL to complete the connection.
- code
publishToEndpoint
Publishes a specific release of a project to a connected endpoint.
Parameters
- input
RequestPublishToEndpointInput(required) — Details for publishing to the endpoint.- did
string(required) — The DID of the blocklet owning the project. - endpointId
string(required) — The ID of the target endpoint. - projectId
string(required) — The ID of the project being published. - releaseId
string(required) — The ID of the release to publish.
- did
Example
Publish to Endpoint
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { url } = await client.mutation.publishToEndpoint({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
endpointId: 'endpoint_xyz',
projectId: 'project_12345',
releaseId: 'release_67890',
},
});
console.log('Publish to endpoint URL:', url);
} catch (error) {
console.error('Error publishing to endpoint:', error);
}Response
- ResponsePublishToEndpoint
object- code
StatusCode— Indicates the result of the operation. - url
string— A URL to track the publishing status.
- code
disconnectFromEndpoint
Disconnects a project from a publishing endpoint.
Parameters
- input
RequestDisconnectFromEndpointInput(required) — Details for disconnecting from the endpoint.- did
string(required) — The DID of the blocklet owning the project. - endpointId
string(required) — The ID of the endpoint to disconnect from. - projectId
string(required) — The ID of the project.
- did
Example
Disconnect from Endpoint
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.disconnectFromEndpoint({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
endpointId: 'endpoint_xyz',
projectId: 'project_12345',
},
});
console.log('Successfully disconnected from the endpoint.');
} catch (error) {
console.error('Error disconnecting from endpoint:', error);
}Response
- GeneralResponse
object- code
StatusCode— Indicates the result of the operation.
- code
addUploadEndpoint
Adds a new upload endpoint for a team.
Parameters
- input
RequestAddUploadEndpointInput(required) — Details for the new upload endpoint.- teamDid
string(required) — The DID of the team. - url
string(required) — The URL of the upload endpoint. - scope
string— The scope of the endpoint.
- teamDid
Example
Add Upload Endpoint
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.addUploadEndpoint({
input: {
teamDid: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
url: 'https://uploads.example.com',
scope: 'images',
},
});
console.log('Upload endpoint added successfully.');
} catch (error) {
console.error('Error adding upload endpoint:', error);
}Response
- GeneralResponse
object- code
StatusCode— Indicates the result of the operation.
- code
deleteUploadEndpoint
Deletes an existing upload endpoint.
Parameters
- input
RequestDeleteUploadEndpointInput(required) — Details for deleting the upload endpoint.- teamDid
string(required) — The DID of the team. - did
string(required) — The DID of the upload endpoint to delete. - scope
string— The scope of the endpoint. - projectId
string— The ID of the associated project.
- teamDid
Example
Delete Upload Endpoint
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
await client.mutation.deleteUploadEndpoint({
input: {
teamDid: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
did: 'endpoint_did_123',
},
});
console.log('Upload endpoint deleted successfully.');
} catch (error) {
console.error('Error deleting upload endpoint:', error);
}Response
- GeneralResponse
object- code
StatusCode— Indicates the result of the operation.
- code
connectByStudio
Establishes a connection with a Blocklet Store via Blocklet Studio.
Parameters
- input
RequestConnectByStudioInput(required) — Details for connecting via Blocklet Studio.- did
string(required) — The DID of the blocklet. - storeId
string(required) — The ID of the store. - storeUrl
string(required) — The URL of the store. - storeName
string(required) — The name of the store. - blockletTitle
string(required) — The title of the blocklet. - type
string(required) — The connection type. - tenantScope
string— The scope of the tenant. - componentDid
string— The DID of the component. - messageId
string— The message ID for tracking.
- did
Example
Connect by Studio
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
try {
const { url } = await client.mutation.connectByStudio({
input: {
did: 'z8iZpA522J9Q2i8mY8J2mY6J2mY8J2mY6J2',
storeId: 'store_abc',
storeUrl: 'https://studio.blocklet.dev',
storeName: 'Blocklet Studio',
blockletTitle: 'My Awesome Blocklet',
type: 'publish',
},
});
console.log('Connect by Studio URL:', url);
} catch (error) {
console.error('Error connecting by Studio:', error);
}Response
- ResponseConnectByStudio
object- code
StatusCode— Indicates the result of the operation. - url
string— The URL to complete the connection process.
- code