import { nocoApi } from "./common"; import bun from 'bun' import util from 'node:util' const tableId = 'mecdgojq151iwk9'; // starred_repos const res = await nocoApi.meta.webhooks.listTableWebhooks(tableId); console.log('表格 Webhook 列表:'); console.log(util.inspect(res, { depth: null })); // { // id: 'hkc9lp4n3w7co4l6', // source_id: 'bdva8kahx60lu45', // base_id: 'pdzc3q50vwnng5r', // fk_model_id: 'mecdgojq151iwk9', // title: '更新列表', // description: null, // env: 'all', // type: null, // event: 'after', // operation: [ 'insert', 'update', 'delete' ], // async: false, // payload: true, // url: null, // headers: null, // condition: false, // notification: '{"type":"URL","include_user":false,"payload":{"method":"POST","body":"{{ json event }}","headers":[{"enabled":false,"name":"","value":""}],"parameters":[{"enabled":false,"name":"tableId","value":"mecdgojq151iwk9"}],"path":"https://kevision.xiongxiao.me/api/router","auth":""},"trigger_form":false}', // retries: 0, // retry_interval: 60000, // timeout: 60000, // active: true, // created_at: '2025-11-29 01:57:05+00:00', // updated_at: '2025-11-29 02:05:31+00:00', // version: 'v3', // trigger_field: false, // trigger_fields: [] // } const hookNotify = { "type": "URL", "include_user": false, "payload": { "method": "POST", "body": "{{ json event }}", "headers": [{ "enabled": false, "name": "", "value": "" }], "parameters": [{ "enabled": false, "name": "tableId", "value": "mecdgojq151iwk9" }], "path": "https://kevision.xiongxiao.me/api/router", "auth": "" }, "trigger_form": false } const createHook = await nocoApi.meta.webhooks.createTableWebhook(tableId, { title: '测试通过 API 创建的 Webhook2', // operation: ['insert', 'update', 'delete'], operation: ['insert', 'update', 'delete'], notification: hookNotify, event: 'manual', }); console.log('创建 Webhook 结果:'); console.log(util.inspect(createHook, { depth: null }));