/** * eventscripts.js — Core whitelisted event scripts (apxtri/dataprocess). * * This is the DEFAULT script module shipped with apxtri. It lives in the * repository at {NODEPATH}/apxtri/dataprocess/ so every instance gets it. * * An instance may override it with its own module at * {NODEPATH}/{TOWN}/dataprocess/eventscripts.js (checked first by the events * runner). The core module is used when no instance override exists. * * Each exported function can be called from an event via `script: { name, params }`. * The function receives: * params — the JSON parameters stored on the event (validated INSIDE this function) * ctx — { tribe, event, alias } (run context: tribe id, the event item, the requesting alias) * * SECURITY: * - Only functions exported here are callable from the /events/run endpoint. * - Each function MUST validate its own `params` before doing anything. * - Functions run in-process; keep them fast and side-effect-free unless intended. * - Never execute arbitrary shell commands here. */ module.exports = { /** * Example no-op function. * Validates that `params.message` is a non-empty string, then echoes it. */ example: function (params, ctx) { if (!params || typeof params.message !== 'string' || !params.message.trim()) { throw new Error('invalid params: "message" (string) is required'); } return { ok: true, echo: params.message.trim(), tribe: ctx.tribe, at: new Date().toISOString() }; }, // --- Add your tribe's authorized event scripts below --- // e.g. sendNotification: function (params, ctx) { ... }, };