fix: preserve value types in extraFields (no string coercion)
CI / typecheck + build (turbo) (push) Canceled after 0s
CI / typecheck + build (turbo) (push) Canceled after 0s
- DocumentMeta.extraFields type -> Record<string, unknown> - API routes pass extraFields through without JSON.stringify coercion - CustomFieldBadges auto-styles by value type/content (number->purple, boolean->green/red, etc.) - DocForm help text: generic (no hardcoded field examples)
This commit is contained in:
@@ -68,14 +68,7 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
try {
|
||||
const { standard, extraFields } = splitPayload(body);
|
||||
// Coerce all extra field values to strings (form sends strings; API/MCP may send objects).
|
||||
const stringExtra: Record<string, string> = {};
|
||||
for (const [k, v] of Object.entries(extraFields)) {
|
||||
if (v !== undefined && v !== null) {
|
||||
stringExtra[k] = typeof v === "string" ? v : JSON.stringify(v);
|
||||
}
|
||||
}
|
||||
const doc = await createDocument({ ...standard, extraFields: stringExtra } as any);
|
||||
const doc = await createDocument({ ...standard, extraFields } as any);
|
||||
return NextResponse.json({ ok: true, slug: doc.slug, doc });
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
|
||||
Reference in New Issue
Block a user