Files
picpeak/backend/src/services/workflows/index.js
T
Luca b48d8c2eb8 feat(workflows): approval gates — email confirm/deny + token resume
gate_setup action creates a workflow_approvals row (single-use token stored
as SHA-256 hash) and emails the admin confirm/deny links immediately
(internal mail, no business-hours floor). actByToken / actById finalize the
approval and resume the run down the matching confirm/deny edge; both are
idempotent (a second click → 'already recorded') and respect expiry. Public
GET /api/public/workflow-approvals/:token/:action returns a small HTML
confirmation page (clickable from email, single-use so prefetch can't
double-act). listPending backs the webview inbox (wired in the CRUD phase).
Test covers gate→approval→email→token-confirm→resume + idempotency.
2026-06-23 02:37:20 +02:00

23 lines
753 B
JavaScript

/**
* Workflow engine public surface.
*
* const { emitWorkflowEvent } = require('./services/workflows');
*
* `engine` holds the executor (start/advance/resume), `registry` the catalog
* of conditions/actions. Action/condition handler modules require `registry`
* and call registerAction/registerCondition at load time.
*/
const engine = require('./engine');
const registry = require('./registry');
// Side-effect import: registers the data-touching action/condition handlers
// (send_email, invoice_paid, prepare_* document actions) onto the registry.
require('./actions');
// Registers the gate_setup action + exposes approval helpers.
const approvals = require('./approvals');
module.exports = {
...engine,
...approvals,
registry,
};