W n8n
This commit is contained in:
parent
67f495872f
commit
543a964235
File diff suppressed because one or more lines are too long
@ -20,11 +20,11 @@ interface MissionCreateInput {
|
||||
guardians?: Record<string, string>;
|
||||
volunteers?: string[];
|
||||
logo?: string | null;
|
||||
leantimeProjectId?: string;
|
||||
documentationCollectionId?: string;
|
||||
rocketchatChannelId?: string;
|
||||
gitRepoUrl?: string;
|
||||
penpotProjectId?: string;
|
||||
leantimeProjectId?: string | null;
|
||||
outlineCollectionId?: string | null;
|
||||
rocketChatChannelId?: string | null;
|
||||
giteaRepositoryUrl?: string | null;
|
||||
penpotProjectId?: string | null;
|
||||
creatorId?: string;
|
||||
}
|
||||
|
||||
@ -34,6 +34,26 @@ interface MissionUserInput {
|
||||
missionId: string;
|
||||
}
|
||||
|
||||
interface MissionResponse {
|
||||
name: string;
|
||||
oddScope: string[];
|
||||
niveau: string;
|
||||
intention: string;
|
||||
missionType: string;
|
||||
donneurDOrdre: string;
|
||||
projection: string;
|
||||
services: string[];
|
||||
profils: string[];
|
||||
participation: string;
|
||||
creatorId: string;
|
||||
logo: string | null;
|
||||
leantimeProjectId: string | null;
|
||||
outlineCollectionId: string | null;
|
||||
rocketChatChannelId: string | null;
|
||||
giteaRepositoryUrl: string | null;
|
||||
penpotProjectId: string | null;
|
||||
}
|
||||
|
||||
// Helper function to check authentication
|
||||
async function checkAuth(request: Request) {
|
||||
const apiKey = request.headers.get('x-api-key');
|
||||
@ -171,9 +191,9 @@ export async function POST(request: Request) {
|
||||
where: { id: existingMission.id },
|
||||
data: {
|
||||
leantimeProjectId: body.leantimeProjectId ? String(body.leantimeProjectId) : null,
|
||||
outlineCollectionId: body.documentationCollectionId || null,
|
||||
rocketChatChannelId: body.rocketchatChannelId || null,
|
||||
giteaRepositoryUrl: body.gitRepoUrl || null,
|
||||
outlineCollectionId: body.outlineCollectionId || null,
|
||||
rocketChatChannelId: body.rocketChatChannelId || null,
|
||||
giteaRepositoryUrl: body.giteaRepositoryUrl || null,
|
||||
penpotProjectId: body.penpotProjectId || null
|
||||
} as Prisma.MissionUpdateInput
|
||||
});
|
||||
@ -318,9 +338,9 @@ export async function POST(request: Request) {
|
||||
creatorId: creatorId,
|
||||
logo: body.logo || null,
|
||||
leantimeProjectId: body.leantimeProjectId ? String(body.leantimeProjectId) : null,
|
||||
outlineCollectionId: body.documentationCollectionId || null,
|
||||
rocketChatChannelId: body.rocketchatChannelId || null,
|
||||
giteaRepositoryUrl: body.gitRepoUrl || null,
|
||||
outlineCollectionId: body.outlineCollectionId || null,
|
||||
rocketChatChannelId: body.rocketChatChannelId || null,
|
||||
giteaRepositoryUrl: body.giteaRepositoryUrl || null,
|
||||
penpotProjectId: body.penpotProjectId || null
|
||||
} as Prisma.MissionUncheckedCreateInput
|
||||
});
|
||||
@ -362,25 +382,58 @@ export async function POST(request: Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// Format response to match workflow output
|
||||
const missionResponse: MissionResponse = {
|
||||
name: mission.name,
|
||||
oddScope: mission.oddScope,
|
||||
niveau: mission.niveau,
|
||||
intention: mission.intention,
|
||||
missionType: mission.missionType,
|
||||
donneurDOrdre: mission.donneurDOrdre,
|
||||
projection: mission.projection,
|
||||
services: mission.services,
|
||||
profils: mission.profils,
|
||||
participation: mission.participation || 'default',
|
||||
creatorId: mission.creatorId,
|
||||
logo: mission.logo,
|
||||
leantimeProjectId: (mission as any).leantimeProjectId,
|
||||
outlineCollectionId: (mission as any).outlineCollectionId,
|
||||
rocketChatChannelId: (mission as any).rocketChatChannelId,
|
||||
giteaRepositoryUrl: (mission as any).giteaRepositoryUrl,
|
||||
penpotProjectId: (mission as any).penpotProjectId
|
||||
};
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
status: 'success',
|
||||
message: 'Mission created successfully',
|
||||
mission
|
||||
mission: missionResponse,
|
||||
integrationStatus: {
|
||||
leantimeProject: !!missionResponse.leantimeProjectId,
|
||||
outlineCollection: !!missionResponse.outlineCollectionId,
|
||||
rocketChatChannel: !!missionResponse.rocketChatChannelId,
|
||||
giteaRepository: !!missionResponse.giteaRepositoryUrl
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error creating mission:', error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
if (error.code === 'P2003') {
|
||||
return NextResponse.json({
|
||||
error: 'Invalid reference',
|
||||
details: 'One or more referenced users do not exist',
|
||||
success: false,
|
||||
status: 'error',
|
||||
error: 'Invalid reference',
|
||||
message: 'One or more referenced users do not exist',
|
||||
code: 'INVALID_REFERENCE'
|
||||
}, { status: 400 });
|
||||
}
|
||||
}
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Failed to create mission',
|
||||
details: error instanceof Error ? error.message : String(error)
|
||||
success: false,
|
||||
status: 'error',
|
||||
error: 'Failed to create mission',
|
||||
message: error instanceof Error ? error.message : String(error)
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user