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

58
dev/compose.staging.yml Normal file
View file

@ -0,0 +1,58 @@
# Staging stack template (run on the staging host only — never on prod).
#
# 1. Restore an anonymized DB dump into the `db` service.
# 2. Copy (or rsync) a subset of prod uploads into the `uploads` volume.
# 3. Deploy the extension with dev/deploy-staging.sh, then start this stack.
#
# Keep ports/volumes/network distinct from the prod stack.
name: land-nest-staging
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_USER: directus
POSTGRES_PASSWORD: change-me
POSTGRES_DB: directus
volumes:
- db-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U directus"]
interval: 5s
timeout: 5s
retries: 20
directus:
image: directus/directus:11.17.4
ports:
- "8056:8055"
depends_on:
db:
condition: service_healthy
environment:
KEY: change-me
SECRET: change-me-to-at-least-32-bytes-long
ADMIN_EMAIL: staging@example.com
ADMIN_PASSWORD: change-me
DB_CLIENT: pg
DB_HOST: db
DB_PORT: "5432"
DB_DATABASE: directus
DB_USER: directus
DB_PASSWORD: change-me
STORAGE_LOCATIONS: local
STORAGE_LOCAL_ROOT: /directus/uploads
EXTENSIONS_AUTO_RELOAD: "true"
CACHE_ENABLED: "false"
RATE_LIMITER_ENABLED: "false"
IMAGE_PREVIEWS_ENABLED: "true"
IMAGE_PREVIEWS_CONCURRENCY: "1"
LOG_LEVEL: info
volumes:
- uploads:/directus/uploads
- ./extensions:/directus/extensions
volumes:
db-data:
uploads: