Implements createFromWizard and createFromUpload service paths covering the documenso-template, in-app, and upload pathways. Persists subject FK, signers, watchers, and the per-document reminder controls (remindersDisabled / reminderCadenceOverride) introduced in PR1. New POST /api/v1/documents/wizard route and a functional /documents/new UI with type/source/template/signers/reminders sections. Drag-handle reorder, watcher autocomplete picker, and PDF preview defer to the PR10 polish sweep. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
25 lines
851 B
TypeScript
25 lines
851 B
TypeScript
import { NextResponse } from 'next/server';
|
|
|
|
import { withAuth, withPermission } from '@/lib/api/helpers';
|
|
import { parseBody } from '@/lib/api/route-helpers';
|
|
import { errorResponse } from '@/lib/errors';
|
|
import { createFromWizard } from '@/lib/services/documents.service';
|
|
import { createDocumentWizardSchema } from '@/lib/validators/documents';
|
|
|
|
export const POST = withAuth(
|
|
withPermission('documents', 'create', async (req, ctx) => {
|
|
try {
|
|
const body = await parseBody(req, createDocumentWizardSchema);
|
|
const doc = await createFromWizard(ctx.portId, body, {
|
|
userId: ctx.userId,
|
|
portId: ctx.portId,
|
|
ipAddress: ctx.ipAddress,
|
|
userAgent: ctx.userAgent,
|
|
});
|
|
return NextResponse.json({ data: doc }, { status: 201 });
|
|
} catch (error) {
|
|
return errorResponse(error);
|
|
}
|
|
}),
|
|
);
|