feat(editor): bridge the advanced photo editor into the event workflow
CI / build (push) Has been cancelled

Event photos can now be opened in Lumenroom, a WebGL2 develop module, from the
photo editor's Advanced button. The dashboard signs a short-lived token scoped
to one user and event; Lumenroom exchanges it, imports the event's photo list
and proxies bytes on demand, so nothing is copied and the temporary catalog
expires with the bridge session. Saving in Lumenroom renders the photo and
writes it back as the event's edited JPEG, with the advanced recipe kept in
event_photos.advanced_edit_json.

Lumenroom is vendored under lumenroom/ and built as a second compose service,
so one clone and `docker compose up -d --build` deploys both apps.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-21 01:34:20 +00:00
parent 982f9048e1
commit 0cb315ea88
89 changed files with 22087 additions and 1 deletions
@@ -0,0 +1,83 @@
import { NextRequest } from "next/server";
import {
authenticateBridge,
getBridgeEventSummary,
listBridgePhotos,
} from "@/db/bridge";
import { bridgeReturnUrl } from "@/lib/bridge";
import { errorResponse, jsonResponse } from "@/lib/http";
import { mediaStorage } from "@/lib/media-storage";
import { eventPhotoPath } from "@/lib/event-photos";
import sharp from "sharp";
/** Reads the header dimensions without decoding the whole file. */
async function imageSize(
path: string,
): Promise<{ width: number; height: number } | null> {
try {
const meta = await sharp(path).metadata();
if (!meta.width || !meta.height) return null;
return { width: meta.width, height: meta.height };
} catch {
return null;
}
}
/**
* GET /api/bridge/sessions/:sessionId
*
* Everything the advanced editor needs to mirror one event: its title, dates
* and photo list. Photo bytes are fetched separately, one at a time, so opening
* a large event does not transfer gigabytes up front.
*/
export const GET = async (
req: NextRequest,
{ params }: { params: Promise<{ sessionId: string }> },
) => {
const { sessionId } = await params;
const auth = await authenticateBridge(req, sessionId);
if (!auth) return errorResponse(401, "invalid or expired bridge session");
const event = await getBridgeEventSummary(auth.session.eventId);
if (!event) return errorResponse(404, "unknown event");
const rows = await listBridgePhotos(auth.session.eventId);
const storage = await mediaStorage();
if (!storage.ok) return errorResponse(503, storage.message);
// Dimensions are only known for browser images; RAW dimensions arrive with
// the proxy the editor builds from the original.
const sizes = new Map<string, { width: number; height: number }>();
for (const row of rows) {
if (row.kind !== "image") continue;
const size = await imageSize(
eventPhotoPath(storage.root, row.storedName),
).catch(() => null);
if (size) sizes.set(row.id, size);
}
return jsonResponse({
session: { id: auth.session.id, expiresAt: auth.session.expiresAt },
event: {
id: event.id,
title: event.title,
eventType: event.eventType,
startsAt: event.startsAt,
endsAt: event.endsAt,
location: event.location,
description: event.description,
},
photos: rows.map((row) => ({
id: row.id,
filename: row.filename,
mimeType: row.mimeType,
kind: row.kind,
sizeBytes: row.sizeBytes,
folderName: row.folderName,
width: sizes.get(row.id)?.width ?? 0,
height: sizes.get(row.id)?.height ?? 0,
takenAt: row.createdAt,
})),
editor: { returnUrl: bridgeReturnUrl(auth.session.eventId) },
});
};