- Introduced new components for form selection and gateway condition management within the process builder. - Implemented a `FormSelector` component for selecting and managing forms, including search functionality and loading states. - Developed a `GatewayConditionManager` component to manage conditions for gateways, allowing users to define and edit conditions visually. - Created a `ProcessBuilderComponents` component to facilitate the addition of core components in the process builder. - Enhanced the `ProcessFlowCanvas` to support new features, including edge selection and improved node management. - Updated the backend API to handle CRUD operations for forms and processes, including error handling for associated tasks. - Integrated new database models for forms and processes in Prisma, ensuring proper relationships and data integrity. - Improved state management in the form builder store to accommodate new features and enhance user experience.
46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
import { PrismaClient } from '@prisma/client';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
|
// Initialize Prisma client
|
|
const prisma = new PrismaClient();
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
// Parse the request body
|
|
const body = await readBody(event);
|
|
|
|
// Validate required fields
|
|
if (!body.processName) {
|
|
return {
|
|
success: false,
|
|
error: 'Process name is required'
|
|
};
|
|
}
|
|
|
|
// Create a new process in the database
|
|
const process = await prisma.process.create({
|
|
data: {
|
|
processUUID: uuidv4(),
|
|
processName: body.processName,
|
|
processDescription: body.processDescription || null,
|
|
processDefinition: body.definition || { nodes: [], edges: [] },
|
|
processVersion: 1,
|
|
processStatus: body.status || 'draft',
|
|
processCreatedBy: body.createdBy || null // In a real app, this would come from the authenticated user
|
|
}
|
|
});
|
|
|
|
return {
|
|
success: true,
|
|
process
|
|
};
|
|
} catch (error) {
|
|
console.error('Error creating process:', error);
|
|
|
|
return {
|
|
success: false,
|
|
error: 'Failed to create process',
|
|
details: process.env.NODE_ENV === 'development' ? error.message : undefined
|
|
};
|
|
}
|
|
});
|