feat(media): add Convex media archive with backfill and mixed-media library

This commit is contained in:
2026-04-10 15:15:44 +02:00
parent ddb2412349
commit a1df097f9c
26 changed files with 2664 additions and 122 deletions

View File

@@ -1,6 +1,11 @@
type MediaPreviewReference<TStorageId extends string = string> = {
storageId: TStorageId;
kind?: "image" | "video" | "asset";
storageId?: TStorageId;
previewStorageId?: TStorageId;
previewUrl?: string;
originalUrl?: string;
sourceUrl?: string;
url?: string;
};
export function collectMediaStorageIdsForResolution<TStorageId extends string>(
@@ -25,6 +30,10 @@ export function resolveMediaPreviewUrl(
item: MediaPreviewReference,
urlMap: Record<string, string | undefined>,
): string | undefined {
if (item.previewUrl) {
return item.previewUrl;
}
if (item.previewStorageId) {
const previewUrl = urlMap[item.previewStorageId];
if (previewUrl) {
@@ -32,5 +41,21 @@ export function resolveMediaPreviewUrl(
}
}
if (item.originalUrl) {
return item.originalUrl;
}
if (item.sourceUrl) {
return item.sourceUrl;
}
if (item.url) {
return item.url;
}
if (!item.storageId) {
return undefined;
}
return urlMap[item.storageId];
}