update_flow_js_block
Update JavaScript code of a flow page JS block. The code runs in a NocoBase sandbox and uses ctx.render(htmlString) to render output.
Instructions
Update the JavaScript code of a JSBlockModel inside a flowPage. Code runs in NocoBase sandbox — use ctx.render(htmlString) to render output. Example: ctx.render(<h1>Hello</h1>);
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Flow model UID of the JS block (JSBlockModel) | |
| code | Yes | JavaScript code using ctx.render(htmlString) sandbox API |
Implementation Reference
- src/index.ts:367-390 (registration)Registration of 'update_flow_js_block' tool using server.registerTool().
server.registerTool( "update_flow_js_block", { description: "Update the JavaScript code of a JSBlockModel inside a flowPage. Code runs in NocoBase sandbox — use ctx.render(htmlString) to render output. Example: ctx.render(`<h1>Hello</h1>`);", inputSchema: { uid: z.string().describe("Flow model UID of the JS block (JSBlockModel)"), code: z.string().describe("JavaScript code using ctx.render(htmlString) sandbox API"), }, }, async ({ uid, code }) => ok( await nocoFetch("/api/flowModels:save", { method: "POST", body: JSON.stringify({ uid, stepParams: { jsSettings: { runJs: { code, version: "v2" }, }, }, }), }) ) ); - src/index.ts:370-374 (schema)Input schema for update_flow_js_block: expects 'uid' (flow model UID of JSBlockModel) and 'code' (JavaScript using ctx.render sandbox API).
description: "Update the JavaScript code of a JSBlockModel inside a flowPage. Code runs in NocoBase sandbox — use ctx.render(htmlString) to render output. Example: ctx.render(`<h1>Hello</h1>`);", inputSchema: { uid: z.string().describe("Flow model UID of the JS block (JSBlockModel)"), code: z.string().describe("JavaScript code using ctx.render(htmlString) sandbox API"), }, - src/index.ts:376-389 (handler)Handler (async function) that sends a POST to /api/flowModels:save with uid and stepParams.jsSettings.runJs containing the code and version 'v2'.
async ({ uid, code }) => ok( await nocoFetch("/api/flowModels:save", { method: "POST", body: JSON.stringify({ uid, stepParams: { jsSettings: { runJs: { code, version: "v2" }, }, }, }), }) )