feat: premium tier features — auto-backup scheduling, resource alerting, bundled workflows, one-click revert, notification manager

This commit is contained in:
Hermes
2026-05-27 23:39:46 -07:00
parent 6ce0a18f98
commit 11823a1466
19 changed files with 3686 additions and 407 deletions
+65
View File
@@ -0,0 +1,65 @@
const express = require('express');
/**
* Workflows routes factory
* @param {Object} deps - Explicit dependencies
* @param {Object} deps.workflowEngine - WorkflowEngine instance
* @param {Object} deps.licenseManager - License manager for premium gating
* @param {Function} deps.asyncHandler - Async route handler wrapper
* @returns {express.Router}
*/
module.exports = function({ workflowEngine, licenseManager, asyncHandler }) {
const router = express.Router();
// Apply premium gating to all workflows routes
router.use(licenseManager.requirePremium('workflows'));
// ===== WORKFLOW MANAGEMENT ENDPOINTS =====
// List all bundled workflows
router.get('/workflows', asyncHandler(async (req, res) => {
const workflows = workflowEngine.listWorkflows();
res.json({ success: true, workflows });
}, 'workflows-list'));
// Enable a workflow
router.post('/workflows/:workflowId/enable', asyncHandler(async (req, res) => {
const { workflowId } = req.params;
const result = workflowEngine.setWorkflowEnabled(workflowId, true);
res.json({ success: true, ...result });
}, 'workflows-enable'));
// Disable a workflow
router.post('/workflows/:workflowId/disable', asyncHandler(async (req, res) => {
const { workflowId } = req.params;
const result = workflowEngine.setWorkflowEnabled(workflowId, false);
res.json({ success: true, ...result });
}, 'workflows-disable'));
// Manually trigger a workflow
router.post('/workflows/:workflowId/run', asyncHandler(async (req, res) => {
const { workflowId } = req.params;
const triggerData = req.body || {};
triggerData.trigger = 'manual';
const result = await workflowEngine.executeWorkflow(workflowId, triggerData);
res.json({ success: true, result });
}, 'workflows-run'));
// Get execution history for a workflow
router.get('/workflows/:workflowId/history', asyncHandler(async (req, res) => {
const { workflowId } = req.params;
const limit = parseInt(req.query.limit) || 50;
const history = workflowEngine.getHistory(workflowId, limit);
res.json({ success: true, history });
}, 'workflows-history'));
// Get all workflow execution history
router.get('/workflows/history', asyncHandler(async (req, res) => {
const limit = parseInt(req.query.limit) || 100;
const history = workflowEngine.getHistory(null, limit);
res.json({ success: true, history });
}, 'workflows-all-history'));
return router;
};