affine_recover_doc
Restore a document to a specific previous version using its timestamp and unique identifier within an AFFiNE workspace, ensuring precise recovery of content.
Instructions
Recover a doc to a previous timestamp.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| guid | Yes | ||
| timestamp | Yes | ||
| workspaceId | No |
Implementation Reference
- src/tools/history.ts:43-49 (handler)The async handler function that executes the tool logic: performs a GraphQL mutation to recover the document at a specific timestamp.const recoverDocHandler = async (parsed: { workspaceId?: string; guid: string; timestamp: string }) => { const workspaceId = parsed.workspaceId || defaults.workspaceId || parsed.workspaceId; if (!workspaceId) throw new Error("workspaceId required (or set AFFINE_WORKSPACE_ID)"); const mutation = `mutation Recover($workspaceId:String!,$guid:String!,$timestamp:DateTime!){ recoverDoc(workspaceId:$workspaceId, guid:$guid, timestamp:$timestamp) }`; const data = await gql.request<{ recoverDoc: string }>(mutation, { workspaceId, guid: parsed.guid, timestamp: parsed.timestamp }); return text({ recoveredAt: data.recoverDoc }); };
- src/tools/history.ts:50-62 (registration)Registration of the 'affine_recover_doc' tool, specifying title, description, input schema using Zod, and linking to the recoverDocHandler.server.registerTool( "affine_recover_doc", { title: "Recover Document", description: "Recover a doc to a previous timestamp.", inputSchema: { workspaceId: z.string().optional(), guid: z.string(), timestamp: z.string() } }, recoverDocHandler as any );
- src/tools/history.ts:56-59 (schema)Input schema definition for the tool using Zod validators.workspaceId: z.string().optional(), guid: z.string(), timestamp: z.string() }