本節提供用於從您的 Blocklet Server 擷取操作資料的 GraphQL 查詢的詳細參考。這些查詢對於監控系統健康狀況、管理備份、稽核活動以及深入了解流量模式至關重要。有關資料和操作的變更,請參閱 資料與操作變更部分。
備份
管理和監控 blocklet 備份記錄。
getBlockletBackups
擷取特定 blocklet 的備份記錄列表,可選擇按時間範圍篩選。
參數
- input
RequestGetBlockletBackupsInput(required) — 包含查詢參數的物件。- did
string(required) — 要擷取備份的 blocklet 的 DID。 - startTime
string— 備份記錄的時間範圍起點。 - endTime
string— 備份記錄的時間範圍終點。
- did
範例用法
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const backups = await client.getBlockletBackups({
input: { did: 'z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC' }
});
console.log(backups);範例回應
{
"code": "ok",
"backups": [
{
"appPid": "z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC",
"userDid": "z1...",
"strategy": 1,
"sourceUrl": "/path/to/backup",
"target": "disk",
"targetName": "Local Disk",
"targetUrl": "/path/to/backup/target",
"createdAt": 1678886400,
"updatedAt": 1678886400,
"status": 1,
"message": "Backup completed successfully",
"progress": 100,
"metadata": {}
}
]
}getBlockletBackupSummary
擷取指定時間範圍內 blocklet 的備份活動摘要,包括成功和錯誤計數,並按日期分組。
參數
- input
RequestGetBlockletBackupSummaryInput(required) — 包含查詢參數的物件。- did
string(required) — blocklet 的 DID。 - startTime
string— 備份摘要的時間範圍起點。 - endTime
string— 備份摘要的時間範圍終點。
- did
範例用法
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const summary = await client.getBlockletBackupSummary({
input: { did: 'z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC' }
});
console.log(summary);範例回應
{
"code": "ok",
"summary": [
{
"date": "2023-03-15",
"successCount": 5,
"errorCount": 1
}
]
}記錄
存取稽核和活動記錄以進行監控和故障排除。
getAuditLogs
擷取分頁的稽核記錄列表,讓您能追蹤整個節點的活動。您可以按範圍、類別和內容篩選記錄。
參數
- input
RequestGetAuditLogsInput— 包含查詢參數的物件。- paging
PagingInput— 分頁選項。 - scope
string— 按範圍篩選(例如 'node'、'z8ia...')。 - category
string— 按類別篩選(例如 'user'、'blocklet')。 - actionOrContent
string— 用於操作或內容欄位的搜尋字串。
- paging
範例用法
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const logs = await client.getAuditLogs({
input: {
paging: { page: 1, pageSize: 10 },
category: 'user'
}
});
console.log(logs);範例回應
{
"code": "ok",
"list": [
{
"id": "...",
"scope": "node",
"category": "user",
"action": "login",
"content": "User z1... logged in",
"actor": {
"did": "z1...",
"role": "owner",
"fullName": "Alice"
},
"env": {},
"createdAt": 1678886400,
"ip": "127.0.0.1",
"ua": "Mozilla/5.0..."
}
],
"paging": {
"total": 1,
"pageSize": 10,
"pageCount": 1,
"page": 1
}
}getPassportLogs
擷取特定通行證的活動記錄,追蹤發行、撤銷和使用等操作。
參數
- input
RequestPassportLogInput(required) — 包含查詢參數的物件。- teamDid
string(required) — 團隊或 blocklet 的 DID。 - query
PassportLogQueryInput(required) — 查詢篩選器。- passportId
string(required) — 要擷取記錄的通行證 ID。
- passportId
- paging
PagingInput— 分頁選項。
- teamDid
範例用法
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const logs = await client.getPassportLogs({
input: {
teamDid: 'z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC',
query: { passportId: 'zpassport_...' },
paging: { page: 1, pageSize: 10 }
}
});
console.log(logs);範例回應
{
"passportLogs": [
{
"id": 1,
"passportId": "zpassport_...",
"action": "issued",
"operatorIp": "127.0.0.1",
"operatorUa": "Mozilla/5.0...",
"operatorDid": "z1...",
"metadata": {},
"createdAt": 1678886400
}
],
"paging": {
"total": 1,
"pageSize": 10,
"pageCount": 1,
"page": 1
}
}分析與洞察
深入了解 blocklet 的效能和使用情況。
getTrafficInsights
提供特定 blocklet 的流量分析,包括指定日期範圍內的請求計數、獨立訪客數和頻寬使用情況。
參數
- input
RequestGetTrafficInsightsInput(required) — 包含查詢參數的物件。- did
string(required) — blocklet 的 DID。 - startDate
string— 分析期間的開始日期(例如 'YYYY-MM-DD')。 - endDate
string— 分析期間的結束日期(例如 'YYYY-MM-DD')。 - paging
PagingInput— 分頁選項。
- did
範例用法
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
const insights = await client.getTrafficInsights({
input: {
did: 'z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC',
startDate: '2023-01-01',
endDate: '2023-01-31'
}
});
console.log(insights);範例回應
{
"code": "ok",
"list": [
{
"did": "z8ia22V5CfqF2e4sAFc9a2B9z9mC6a8x461sC",
"date": "2023-01-15",
"totalRequests": 1500,
"uniqueVisitors": 200,
"bandwidth": 512000000
}
],
"paging": {
"total": 1,
"pageSize": 10,
"pageCount": 1,
"page": 1
}
}您現在已掌握從 Blocklet Server 查詢操作資料的工具。要了解如何管理發佈工作流程和專案資源,請前往 發佈與專案 部分。