feat: pre-generate Directus image previews

Bundle extension (upload hook + API endpoint + admin module) that warms
Directus image transform cache in-process with an explicit acceptFormat,
so the generated file matches the browser's cache key byte-for-byte.

- resumable, window-aware backfill with progress + cancel
- system + custom presets, effective-format reporting, shadow warnings
- storage breakdown (previews vs originals), human-readable API fields
- diagnostics: resolve-plan prediction, per-file generate, ops ring buffer
- isolated dev/staging compose stack + deploy/rollback scripts

Verified on Directus 11.17.4: 40/40 tests, hash-match gate passed,
idempotent backfill, custom fixed-format presets, error surfacing.
This commit is contained in:
Rawman Grey 2026-10-25 11:19:54 +03:00
commit c8f8bbc5ac
42 changed files with 10005 additions and 0 deletions

50
src/lib/types.ts Normal file
View file

@ -0,0 +1,50 @@
export interface Preset {
key: string;
format?: string;
quality?: number | string;
width?: number | string;
height?: number | string;
fit?: string;
withoutEnlargement?: boolean;
focal_point_x?: number | string | null;
focal_point_y?: number | string | null;
transforms?: unknown[];
[key: string]: unknown;
}
export interface WarmResultItem {
key: string;
format: string | null;
ok: boolean;
ms: number;
error?: string;
}
export interface WarmSummary {
requested: number;
ok: number;
failed: number;
results: WarmResultItem[];
}
export interface CompletedRecord {
file_id: string;
preset_key: string;
format: string | null;
ts: number;
}
export interface RunState {
running: boolean;
startedAt: number | null;
finishedAt: number | null;
total: number;
done: number;
generated: number;
hits: number;
failed: number;
rate: number;
eta: number | null;
cancelled: boolean;
error?: string;
}