feat: PhotoPrism M0 bring-up — compose stack, web client, sidecar, migrate

Replace the legacy mule-image backend with PhotoPrism plus a thin
SvelteKit client and a Node sidecar for endpoints PhotoPrism doesn't
expose (file rename), and add a two-phase migrator (metadata via PUT,
heaps → albums) for the existing Postgres library.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-17 16:06:58 +02:00
parent 423a73a8a6
commit 8c2526d982
69 changed files with 12048 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/**
* Fan-out helper used wherever PhotoPrism lacks a true batch endpoint.
* Bounded concurrency keeps the indexer happy on slow hosts; each item's
* result is collected and the aggregate `{updated, errors[]}` mirrors the
* shape the legacy mule-image bulk endpoint returned, so existing toast
* + undo plumbing slots in without changes.
*/
export interface BatchResult<T> {
updated: T[];
errors: { id: string; message: string }[];
}
export interface BatchOptions {
concurrency?: number;
onProgress?: (done: number, total: number) => void;
}
export async function batchEdit<T>(
ids: string[],
fn: (id: string) => Promise<T>,
opts: BatchOptions = {}
): Promise<BatchResult<T>> {
const concurrency = Math.max(1, opts.concurrency ?? 8);
const updated: T[] = [];
const errors: { id: string; message: string }[] = [];
let i = 0;
let done = 0;
async function worker() {
while (true) {
const idx = i++;
if (idx >= ids.length) return;
const id = ids[idx];
try {
updated.push(await fn(id));
} catch (err) {
errors.push({ id, message: err instanceof Error ? err.message : String(err) });
} finally {
done++;
opts.onProgress?.(done, ids.length);
}
}
}
await Promise.all(
Array.from({ length: Math.min(concurrency, ids.length) }, () => worker())
);
return { updated, errors };
}