メインコンテンツへスキップ

公開とプロジェクト

このセクションでは、Blockletプロジェクトのライフサイクル全体を管理するためのミューテーションについて詳しく説明します。作成やリリース管理から、Blockletストアへの接続、作業の公開までを扱います。これらのミューテーションにより、プロジェクトの開発、バージョン管理、配布方法をプログラムで制御できます。

プロジェクト関連のデータを取得するには、公開とプロジェクトのクエリのドキュメントを参照してください。

プロジェクト管理

これらのミューテーションは、開発プロジェクトの作成、変更、削除を処理します。

createProject

指定されたBlockletコンポーネントの新しいプロジェクトを作成し、将来のリリースと公開のために設定します。

パラメーター

  • input RequestCreateProjectInput (required) — プロジェクトの詳細を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • type PublishType (required) — プロジェクトのタイプ。「resource」または「pack」のいずれか。
    • blockletDid string (required) — 公開されるBlockletのDID。
    • blockletTitle string (required) — Blockletのタイトル。
    • componentDid string — プロジェクトに関連付けられたコンポーネントのDID。
    • tenantScope string — テナントのスコープ。

Create Project

javascript
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);
}

レスポンス

  • ResponseProject object
    • code StatusCode — 操作の結果を示します。
    • project Project — 新しく作成されたプロジェクトオブジェクト。

updateProject

既存のプロジェクトの詳細(タイトル、説明、紹介など)を更新します。

パラメーター

  • input RequestUpdateProjectInput (required) — 更新するプロジェクトの詳細を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • projectId string (required) — 更新するプロジェクトのID。
    • blockletTitle string — Blockletの新しいタイトル。
    • blockletDescription string — Blockletの新しい説明。
    • blockletIntroduction string — Blockletの新しい紹介文。
    • autoUpload boolean — リソースを自動的にアップロードするかどうか。
    • possibleSameStore boolean — 同じストアに公開する可能性があるかどうか。
    • blockletSupport string — BlockletサポートのURL。
    • blockletCommunity string — BlockletコミュニティのURL。
    • blockletHomepage string — BlockletのホームページのURL。

Update Project

javascript
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);
}

レスポンス

  • ResponseProject object
    • code StatusCode — 操作の結果を示します。
    • project Project — 更新されたプロジェクトオブジェクト。

deleteProject

プロジェクトを永久に削除します。この操作は元に戻せません。

パラメーター

  • input RequestProjectInput (required) — プロジェクト識別子を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • projectId string (required) — 削除するプロジェクトのID。

Delete Project

javascript
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);
}

レスポンス

  • GeneralResponse object
    • code StatusCode — 操作の結果を示します。

リリース管理

これらのミューテーションは、プロジェクトのリリースを作成および管理するために使用されます。

createRelease

プロジェクトの新しいリリースを作成し、関連するメタデータとともにBlockletの特定のバージョンをキャプチャします。

パラメーター

  • input RequestCreateReleaseInput (required) — リリースの詳細を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • projectId string (required) — このリリースの対象となるプロジェクトのID。
    • blockletDid string (required) — このリリースのBlockletバージョンのDID。
    • blockletVersion string (required) — Blockletのバージョン番号。
    • note string — リリースノートまたは変更の概要。
    • blockletTitle string — このリリースのタイトル。
    • blockletDescription string — このリリースの説明。
    • blockletScreenshots string[] — スクリーンショットのURLの配列。

Create Release

javascript
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);
}

レスポンス

  • ResponseRelease object
    • code StatusCode — 操作の結果を示します。
    • release Release — 新しく作成されたリリースオブジェクト。

deleteRelease

プロジェクトからリリースを永久に削除します。

パラメーター

  • input RequestReleaseInput (required) — リリース識別子を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • projectId string (required) — リリースを含むプロジェクトのID。
    • releaseId string (required) — 削除するリリースのID。

Delete Release

javascript
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);
}

レスポンス

  • GeneralResponse object
    • code StatusCode — 操作の結果を示します。

リソース管理

このミューテーションは、プロジェクトリリースに関連するリソースを管理するために使用されます。

updateSelectedResources

プロジェクト内のコンポーネントの特定のリリースで選択されたリソースのリストを更新します。

パラメーター

  • input RequestUpdateSelectedResourcesInput (required) — リソース選択の詳細を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • projectId string (required) — プロジェクトのID。
    • releaseId string (required) — リリースのID。
    • componentDid string (required) — リソースが更新されるコンポーネントのDID。
    • resources string[] (required) — 選択されるリソース識別子の配列。

Update Selected Resources

javascript
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);
}

レスポンス

  • GeneralResponse object
    • code StatusCode — 操作の結果を示します。

ストアとエンドポイントの接続

これらのミューテーションは、プロジェクトとBlockletストアやエンドポイントなどのさまざまな公開先との接続を管理します。

connectToStore

プロジェクトとBlockletストア間の接続を開始し、認証プロセスを完了するためのURLを返します。

パラメーター

  • input RequestConnectToStoreInput (required) — ストア接続の詳細を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • storeId string (required) — Blockletストアの一意の識別子。
    • storeUrl string (required) — BlockletストアのURL。
    • storeName string (required) — Blockletストアの名前。
    • projectId string (required) — 接続するプロジェクトのID。

Connect to Store

javascript
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);
}

レスポンス

  • ResponseConnectToStore object
    • code StatusCode — 操作の結果を示します。
    • url string — 接続を完了するための認証URL。

publishToStore

プロジェクトの特定のリリースを接続されたBlockletストアに公開します。

パラメーター

  • input RequestPublishToStoreInput (required) — 公開の詳細を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • projectId string (required) — 公開されるプロジェクトのID。
    • releaseId string (required) — 公開するリリースのID。
    • type string (required) — 公開されるコンテンツのタイプ(例:「resource」)。
    • storeId string (required) — ターゲットとなるBlockletストアのID。

Publish to Store

javascript
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);
}

レスポンス

  • ResponsePublishToStore object
    • code StatusCode — 操作の結果を示します。
    • url string — 公開プロセスのステータスを追跡するためのURL。

disconnectFromStore

プロジェクトをBlockletストアから切断し、関連付けを削除します。

パラメーター

  • input RequestDisconnectFromStoreInput (required) — ストアからの切断に関する詳細を含むオブジェクト。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • storeId string (required) — 切断するストアのID。
    • projectId string (required) — 切断するプロジェクトのID。
    • storeScope string — ストア接続のスコープ。

Disconnect from Store

javascript
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);
}

レスポンス

  • ResponseDisconnectFromStore object
    • code StatusCode — 操作の結果を示します。

connectToAigne

BlockletをAI機能を提供するAIGNEサービスに接続します。

パラメーター

  • input RequestConnectToAigneInput (required) — AIGNE接続の詳細を含むオブジェクト。
    • did string (required) — 接続するBlockletのDID。
    • baseUrl string (required) — AIGNEサービスのベースURL。
    • provider string (required) — AIプロバイダー(例:「openai」)。
    • model string (required) — 使用する特定のモデル(例:「gpt-4」)。

Connect to AIGNE

javascript
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);
}

レスポンス

  • ResponseConnectToEndpoint object
    • code StatusCode — 操作の結果を示します。
    • url string — 接続を完了するための認証URL。

disconnectToAigne

BlockletをAIGNEサービスから切断します。

パラメーター

  • input RequestDisconnectToAigneInput (required) — AIGNEからの切断に関する詳細を含むオブジェクト。
    • did string (required) — 切断するBlockletのDID。
    • url string (required) — 切断するAIGNEサービスのURL。
    • key string (required) — 接続に使用されたAPIキー。

Disconnect from AIGNE

javascript
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);
}

レスポンス

  • GeneralResponse object
    • code StatusCode — 操作の結果を示します。

verifyAigneConnection

BlockletのAIGNEサービスへの接続を確認します。

パラメーター

  • input RequestVerifyAigneConnectionInput (required) — BlockletのDIDを含むオブジェクト。
    • did string (required) — AIGNE接続を確認するBlockletのDID。

Verify AIGNE Connection

javascript
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);
}

レスポンス

  • GeneralResponse object
    • code StatusCode — 操作の結果を示します。

connectToEndpoint

プロジェクトと一般的な公開エンドポイントとの接続を確立します。

パラメーター

  • input RequestConnectToEndpointInput (required) — エンドポイントへの接続の詳細。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • endpointId string (required) — 接続するエンドポイントのID。
    • projectId string (required) — プロジェクトのID。

Connect to Endpoint

javascript
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);
}

レスポンス

  • ResponseConnectToEndpoint object
    • code StatusCode — 操作の結果を示します。
    • url string — 接続を完了するための認証URL。

publishToEndpoint

プロジェクトの特定のリリースを接続されたエンドポイントに公開します。

パラメーター

  • input RequestPublishToEndpointInput (required) — エンドポイントへの公開の詳細。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • endpointId string (required) — ターゲットエンドポイントのID。
    • projectId string (required) — 公開されるプロジェクトのID。
    • releaseId string (required) — 公開するリリースのID。

Publish to Endpoint

javascript
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);
}

レスポンス

  • ResponsePublishToEndpoint object
    • code StatusCode — 操作の結果を示します。
    • url string — 公開ステータスを追跡するためのURL。

disconnectFromEndpoint

プロジェクトを公開エンドポイントから切断します。

パラメーター

  • input RequestDisconnectFromEndpointInput (required) — エンドポイントからの切断の詳細。
    • did string (required) — プロジェクトを所有するBlockletのDID。
    • endpointId string (required) — 切断するエンドポイントのID。
    • projectId string (required) — プロジェクトのID。

Disconnect from Endpoint

javascript
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);
}

レスポンス

  • GeneralResponse object
    • code StatusCode — 操作の結果を示します。

addUploadEndpoint

チームに新しいアップロードエンドポイントを追加します。

パラメーター

  • input RequestAddUploadEndpointInput (required) — 新しいアップロードエンドポイントの詳細。
    • teamDid string (required) — チームのDID。
    • url string (required) — アップロードエンドポイントのURL。
    • scope string — エンドポイントのスコープ。

Add Upload Endpoint

javascript
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);
}

レスポンス

  • GeneralResponse object
    • code StatusCode — 操作の結果を示します。

deleteUploadEndpoint

既存のアップロードエンドポイントを削除します。

パラメーター

  • input RequestDeleteUploadEndpointInput (required) — アップロードエンドポイントを削除するための詳細。
    • teamDid string (required) — チームのDID。
    • did string (required) — 削除するアップロードエンドポイントのDID。
    • scope string — エンドポイントのスコープ。
    • projectId string — 関連するプロジェクトのID。

Delete Upload Endpoint

javascript
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);
}

レスポンス

  • GeneralResponse object
    • code StatusCode — 操作の結果を示します。

connectByStudio

Blocklet Studioを介してBlockletストアとの接続を確立します。

パラメーター

  • input RequestConnectByStudioInput (required) — Blocklet Studioを介して接続するための詳細。
    • did string (required) — BlockletのDID。
    • storeId string (required) — ストアのID。
    • storeUrl string (required) — ストアのURL。
    • storeName string (required) — ストアの名前。
    • blockletTitle string (required) — Blockletのタイトル。
    • type string (required) — 接続タイプ。
    • tenantScope string — テナントのスコープ。
    • componentDid string — コンポーネントのDID。
    • messageId string — 追跡用のメッセージID。

Connect by Studio

javascript
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);
}

レスポンス

  • ResponseConnectByStudio object
    • code StatusCode — 操作の結果を示します。
    • url string — 接続プロセスを完了するためのURL。