Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* Admin Workflows Endpoints
* Automated workflow and task management
*/
import type { ApiEndpoint } from '@/types/api-docs';
export const adminWorkflowsEndpoints: ApiEndpoint[] = [
{
id: 'admin-workflows-list',
method: 'GET',
path: '/api/admin/workflows',
summary: 'List workflows',
description: 'Returns all automated workflows',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
parameters: [
{ name: 'page', type: 'number', required: false, location: 'query', description: 'Page number' },
{ name: 'limit', type: 'number', required: false, location: 'query', description: 'Items per page' },
{ name: 'status', type: 'string', required: false, location: 'query', description: 'Filter by status', enum: ['active', 'paused', 'draft'] },
{ name: 'trigger', type: 'string', required: false, location: 'query', description: 'Filter by trigger type' },
],
responses: [
{
status: 200,
description: 'List of workflows',
example: {
success: true,
data: {
workflows: [
{ id: 1, name: 'Welcome Email', trigger: 'user_registered', status: 'active', executionCount: 500 },
],
pagination: { page: 1, limit: 20, total: 15, totalPages: 1 },
},
},
},
{ status: 403, description: 'Admin access required' },
],
},
{
id: 'admin-workflows-create',
method: 'POST',
path: '/api/admin/workflows',
summary: 'Create workflow',
description: 'Creates a new automated workflow',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'name', type: 'string', required: true, description: 'Workflow name' },
{ name: 'description', type: 'string', required: false, description: 'Workflow description' },
{ name: 'trigger', type: 'object', required: true, description: 'Trigger configuration' },
{ name: 'conditions', type: 'array', required: false, description: 'Workflow conditions' },
{ name: 'actions', type: 'array', required: true, description: 'Actions to execute' },
{ name: 'status', type: 'string', required: false, description: 'Initial status', enum: ['active', 'paused', 'draft'] },
],
example: {
name: 'Welcome Email',
trigger: { type: 'user_registered' },
actions: [{ type: 'send_email', template: 'welcome' }],
},
},
responses: [
{ status: 201, description: 'Workflow created' },
{ status: 400, description: 'Validation failed' },
],
},
{
id: 'admin-workflows-get',
method: 'GET',
path: '/api/admin/workflows/{id}',
summary: 'Get workflow details',
description: 'Returns workflow configuration and execution history',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Workflow ID' },
],
responses: [
{ status: 200, description: 'Workflow details' },
{ status: 404, description: 'Workflow not found' },
],
},
{
id: 'admin-workflows-update',
method: 'PUT',
path: '/api/admin/workflows/{id}',
summary: 'Update workflow',
description: 'Updates an existing workflow',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Workflow ID' },
],
responses: [
{ status: 200, description: 'Workflow updated' },
{ status: 404, description: 'Workflow not found' },
],
},
{
id: 'admin-workflows-delete',
method: 'DELETE',
path: '/api/admin/workflows/{id}',
summary: 'Delete workflow',
description: 'Deletes a workflow',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Workflow ID' },
],
responses: [
{ status: 200, description: 'Workflow deleted' },
{ status: 404, description: 'Workflow not found' },
],
},
{
id: 'admin-workflows-toggle',
method: 'POST',
path: '/api/admin/workflows/{id}/toggle',
summary: 'Toggle workflow status',
description: 'Activates or pauses a workflow',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Workflow ID' },
],
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'status', type: 'string', required: true, description: 'New status', enum: ['active', 'paused'] },
],
},
responses: [
{ status: 200, description: 'Workflow status updated' },
{ status: 404, description: 'Workflow not found' },
],
},
{
id: 'admin-workflows-test',
method: 'POST',
path: '/api/admin/workflows/{id}/test',
summary: 'Test workflow',
description: 'Tests a workflow with sample data without side effects',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Workflow ID' },
],
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'testData', type: 'object', required: true, description: 'Sample data for testing' },
],
},
responses: [
{ status: 200, description: 'Test results', example: { success: true, data: { conditionsMet: true, actionsToExecute: ['send_email'] } } },
{ status: 404, description: 'Workflow not found' },
],
},
{
id: 'admin-workflows-executions',
method: 'GET',
path: '/api/admin/workflows/{id}/executions',
summary: 'Get workflow executions',
description: 'Returns execution history for a workflow',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Workflow ID' },
{ name: 'page', type: 'number', required: false, location: 'query', description: 'Page number' },
{ name: 'limit', type: 'number', required: false, location: 'query', description: 'Items per page' },
{ name: 'status', type: 'string', required: false, location: 'query', description: 'Filter by status', enum: ['success', 'failed', 'skipped'] },
],
responses: [
{ status: 200, description: 'Execution history' },
{ status: 404, description: 'Workflow not found' },
],
},
{
id: 'admin-workflows-trigger',
method: 'POST',
path: '/api/admin/workflows/{id}/trigger',
summary: 'Manually trigger workflow',
description: 'Manually triggers a workflow execution with provided data',
category: 'admin-workflows',
requiresAuth: true,
adminOnly: true,
parameters: [
{ name: 'id', type: 'number', required: true, location: 'path', description: 'Workflow ID' },
],
requestBody: {
contentType: 'application/json',
fields: [
{ name: 'data', type: 'object', required: true, description: 'Trigger data' },
{ name: 'targetUsers', type: 'array', required: false, description: 'Specific user IDs to target' },
],
example: {
data: { campaignId: 123 },
targetUsers: [1, 2, 3],
},
},
responses: [
{ status: 200, description: 'Workflow triggered', example: { success: true, data: { executionId: 456, queued: 100 } } },
{ status: 400, description: 'Workflow not active or invalid data' },
{ status: 404, description: 'Workflow not found' },
],
},
];
|