Barrel-split pattern: each original becomes a thin re-export barrel; logic moved to sibling files so no consumer imports need updating. Files split: - loeschfristen-profiling.ts → profiling-data.ts + profiling-generator.ts - vendor-compliance/catalog/vendor-templates.ts → vendor-country-profiles.ts - vendor-compliance/catalog/legal-basis.ts → legal-basis-retention.ts - dsfa/eu-legal-frameworks.ts → eu-legal-frameworks-national.ts - compliance-scope-types/document-scope-matrix-core.ts → core-part2.ts - compliance-scope-types/document-scope-matrix-extended.ts → extended-part2.ts - app/sdk/document-generator/contextBridge.ts → contextBridge-helpers.ts - app/api/sdk/drafting-engine/draft/route.ts → draft-helpers.ts + draft-helpers-v2.ts All files ≤ 500 LOC. Zero behavior changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
/**
|
|
* Drafting Engine - Draft API v2
|
|
*
|
|
* Erstellt personalisierte Compliance-Dokument-Entwuerfe.
|
|
* Pipeline: Constraint → Context → Sanitize → LLM → Validate → Repair → Merge
|
|
*
|
|
* v1-Modus: ?v=1 oder fehlender v2-Kontext → Legacy-Pipeline
|
|
* v2-Modus: Standard — Personalisierte Prosa mit Governance
|
|
*/
|
|
|
|
import { NextRequest, NextResponse } from 'next/server'
|
|
import { handleV1Draft, handleV2Draft } from './draft-helpers'
|
|
|
|
// ============================================================================
|
|
// Route Handler
|
|
// ============================================================================
|
|
|
|
export async function POST(request: NextRequest) {
|
|
try {
|
|
const body = await request.json()
|
|
const { documentType, draftContext } = body
|
|
|
|
if (!documentType || !draftContext) {
|
|
return NextResponse.json(
|
|
{ error: 'documentType und draftContext sind erforderlich' },
|
|
{ status: 400 }
|
|
)
|
|
}
|
|
|
|
// v1 fallback: explicit ?v=1 parameter
|
|
const version = request.nextUrl.searchParams.get('v')
|
|
if (version === '1') {
|
|
return handleV1Draft(body)
|
|
}
|
|
|
|
// Default: v2 pipeline
|
|
return handleV2Draft(body)
|
|
} catch (error) {
|
|
console.error('Draft generation error:', error)
|
|
return NextResponse.json(
|
|
{ error: 'Draft-Generierung fehlgeschlagen.' },
|
|
{ status: 503 }
|
|
)
|
|
}
|
|
}
|