Files
photoreport/apps/api/src/library/serialize.ts
T
spark cda3885fcd
ci / rust (push) Successful in 7m47s
ci / typescript (push) Successful in 10m34s
Library: Send button, combinable filters and delivery state
The top bar sends the selection (rejects never) to a destination, or leads to setting one up. Filters combine as in Photo Mechanic (flag, stars at least, colour, delivery: to send / sending / sent / failed, without players); each thumbnail shows whether it was sent, live.

Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-13 17:11:29 +01:00

47 lines
1.7 KiB
TypeScript

import { deliveryState, type PhotoSummary } from "@photoreport/contracts";
import type { Photo } from "../generated/prisma/client.js";
import type { UrlSigner } from "../storage/storage.js";
import { deliveredName } from "../delivery/service.js";
export type PhotoWithUploader = Photo & { uploader: { id: string; name: string } | null; deliveries?: { status: string }[] };
export const photoInclude = { uploader: { select: { id: true, name: true } }, deliveries: { select: { status: true } } } as const;
export function toSummary(photo: PhotoWithUploader, signer: UrlSigner): PhotoSummary {
return {
id: photo.id,
eventId: photo.eventId,
originalName: photo.originalName,
name: deliveredName(photo),
sha256: photo.sha256,
originalStored: photo.originalStored,
status: photo.status,
...(photo.status === "FAILED" && { error: photo.error }),
...(photo.deliveries && { delivery: deliveryState(photo.deliveries.map((d) => d.status)) }),
width: photo.width,
height: photo.height,
capturedAt: photo.capturedAt?.toISOString() ?? null,
cameraModel: photo.cameraModel,
lens: photo.lens,
focalLength: photo.focalLength,
aperture: photo.aperture,
exposureTime: photo.exposureTime,
iso: photo.iso,
rating: photo.rating,
flag: photo.flag,
colorLabel: photo.colorLabel,
players: photo.players,
uploader: photo.uploader,
developSeq: photo.developSeq,
urls: photoUrls(photo, signer),
};
}
export function photoUrls(photo: { id: string; renderedSeq: number }, signer: UrlSigner): PhotoSummary["urls"] {
return {
thumb: signer.url(photo.id, "thumb", photo.renderedSeq),
preview: signer.url(photo.id, "preview", photo.renderedSeq),
source: signer.url(photo.id, "source"),
};
}