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

21
dev/deploy-staging.sh Executable file
View file

@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Deploy the built extension to a STAGING Directus extensions dir. Never target prod.
# Usage: ./dev/deploy-staging.sh <ssh-host> <staging-extensions-root>
set -euo pipefail
HOST="${1:?usage: deploy-staging.sh <ssh-host> <staging-extensions-root>}"
EXT_ROOT="${2:?usage: deploy-staging.sh <ssh-host> <staging-extensions-root>}"
NAME="directus-extension-generate-image-previews"
STAMP="$(date +%Y%m%d-%H%M%S)"
cd "$(dirname "$0")/.."
npm run build
ssh "$HOST" "mkdir -p '$EXT_ROOT/$NAME' && if [ -d '$EXT_ROOT/$NAME/dist' ]; then cp -a '$EXT_ROOT/$NAME/dist' '$EXT_ROOT/$NAME/dist.bak-$STAMP'; fi"
rsync -az --delete dist/ "$HOST:$EXT_ROOT/$NAME/dist/"
scp package.json "$HOST:$EXT_ROOT/$NAME/package.json"
echo "deployed to $HOST:$EXT_ROOT/$NAME (backup stamp: $STAMP)"
echo "restart staging Directus, then check: docker logs <staging-directus> | grep -i 'loaded extensions'"