feat: persist metafield resolutions across sessions

Les associations colonne→métachamp sont sauvegardées dans data/metafield-resolutions.json
et rechargées automatiquement à la prochaine création de produits.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 15:28:53 +02:00
parent caef95bd55
commit 114e20c9fb
3 changed files with 62 additions and 7 deletions
+20
View File
@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from 'next/server'
import { getServerSession } from 'next-auth'
import { authOptions } from '@/lib/auth'
import { loadResolutionCache, saveResolutionCache } from '@/lib/resolutionCache'
import type { MetafieldResolution } from '@/types/creation'
export async function GET() {
const session = await getServerSession(authOptions)
if (!session) return NextResponse.json({ error: 'Non authentifié' }, { status: 401 })
const cache = await loadResolutionCache()
return NextResponse.json(cache)
}
export async function PUT(req: NextRequest) {
const session = await getServerSession(authOptions)
if (!session) return NextResponse.json({ error: 'Non authentifié' }, { status: 401 })
const body = await req.json() as Record<string, MetafieldResolution>
await saveResolutionCache(body)
return NextResponse.json({ ok: true })
}