chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:37:47 +08:00
commit 7653f56fed
1422 changed files with 359026 additions and 0 deletions
@@ -0,0 +1,43 @@
import { NextRequest, NextResponse } from 'next/server';
import { getApprovalRecord } from '@/lib/approval/approval-store';
export const dynamic = 'force-dynamic';
/**
* GET /api/approval/[approvalId]/resume - Get workflow resume data
* This endpoint returns the execution state needed to resume the workflow
*/
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ approvalId: string }> }
) {
const { approvalId } = await params;
if (!approvalId) {
return NextResponse.json(
{ success: false, error: 'Approval ID is required' },
{ status: 400 }
);
}
const record = await getApprovalRecord(approvalId);
if (!record) {
return NextResponse.json(
{ success: false, error: 'Approval record not found' },
{ status: 404 }
);
}
if (record.status === 'pending') {
return NextResponse.json(
{ success: false, error: 'Approval is still pending' },
{ status: 400 }
);
}
return NextResponse.json({
success: true,
approved: record.status === 'approved',
record,
});
}
@@ -0,0 +1,90 @@
import { NextRequest, NextResponse } from 'next/server';
import { getApprovalRecord, updateApprovalRecord } from '@/lib/approval/approval-store';
export const dynamic = 'force-dynamic';
/**
* GET /api/approval/[approvalId] - Get approval status
*/
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ approvalId: string }> }
) {
const { approvalId } = await params;
if (!approvalId) {
return NextResponse.json(
{ success: false, error: 'Approval ID is required' },
{ status: 400 }
);
}
const record = await getApprovalRecord(approvalId);
if (!record) {
return NextResponse.json(
{ success: false, error: 'Approval record not found' },
{ status: 404 }
);
}
return NextResponse.json({
success: true,
record,
});
}
/**
* POST /api/approval/[approvalId] - Approve or reject
*/
export async function POST(
request: NextRequest,
{ params }: { params: Promise<{ approvalId: string }> }
) {
const { approvalId } = await params;
if (!approvalId) {
return NextResponse.json(
{ success: false, error: 'Approval ID is required' },
{ status: 400 }
);
}
try {
const body = await request.json();
const { action, userId } = body;
if (action !== 'approve' && action !== 'reject') {
return NextResponse.json(
{ success: false, error: 'Action must be "approve" or "reject"' },
{ status: 400 }
);
}
const status = action === 'approve' ? 'approved' : 'rejected';
const record = await updateApprovalRecord(approvalId, {
status,
resolvedBy: userId,
});
if (!record) {
return NextResponse.json(
{ success: false, error: 'Approval record not found' },
{ status: 404 }
);
}
return NextResponse.json({
success: true,
record,
});
} catch (error) {
console.error('Failed to update approval:', error);
return NextResponse.json(
{
success: false,
error: error instanceof Error ? error.message : 'Failed to update approval',
},
{ status: 500 }
);
}
}
@@ -0,0 +1,42 @@
import { NextRequest, NextResponse } from 'next/server';
import { createOrUpdateApprovalRecord } from '@/lib/approval/approval-store';
export const dynamic = 'force-dynamic';
/**
* POST /api/approval - Create a new approval request
*/
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const { approvalId, executionId, workflowId, nodeId, message, userId } = body;
if (!approvalId || !executionId || !workflowId || !nodeId) {
return NextResponse.json(
{ success: false, error: 'Missing required fields' },
{ status: 400 }
);
}
const record = await createOrUpdateApprovalRecord({
approvalId,
executionId,
workflowId,
nodeId,
message: message || 'Approval required',
userId,
status: 'pending',
});
return NextResponse.json({ success: true, record });
} catch (error) {
console.error('Failed to create approval record:', error);
return NextResponse.json(
{
success: false,
error: error instanceof Error ? error.message : 'Failed to create approval',
},
{ status: 500 }
);
}
}