/**
 * POST /api/marketplace/sync-all
 *
 * Single entry point that refreshes every kind of marketplace data
 * from every configured source (public + each enterprise tenant):
 *   - connector registry + manifests + wizard templates
 *   - workflows (pipelines + recipes)
 *   - skills
 *
 * Replaces the per-tab Sync buttons that each only refreshed one type
 * (and silently skipped enterprise sources for skills). Settings →
 * Re-sync registry calls this same endpoint.
 */

import { NextResponse } from 'next/server';
import { syncAll } from '@/lib/marketplace-sync';

export async function POST() {
  try {
    const r = await syncAll();
    return NextResponse.json(r, { status: r.ok ? 200 : 207 });
  } catch (e) {
    return NextResponse.json(
      { ok: false, error: (e as Error).message },
      { status: 500 },
    );
  }
}
