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

63
package.json Normal file
View file

@ -0,0 +1,63 @@
{
"name": "directus-extension-generate-image-previews",
"description": "Pre-generate Directus image transforms: on upload, on demand, and via a scheduled resumable backfill, with an admin UI (progress, disk usage, maintenance window)",
"author": {
"name": "Rawman Grey",
"email": "rawman@locus.im",
"url": "https://locus.im"
},
"icon": "extension",
"version": "0.1.0",
"keywords": [
"directus",
"directus-extension",
"directus-extension-bundle"
],
"type": "module",
"files": [
"dist"
],
"directus:extension": {
"type": "bundle",
"path": {
"app": "dist/app.js",
"api": "dist/api.js"
},
"entries": [
{
"type": "module",
"name": "image-previews",
"source": "src/module/index.ts"
},
{
"type": "hook",
"name": "image-previews-hook",
"source": "src/hook/index.ts"
},
{
"type": "endpoint",
"name": "image-previews-endpoint",
"source": "src/endpoint/index.ts"
}
],
"host": "^10.10.0 || ^11.0.0"
},
"scripts": {
"build": "directus-extension build",
"dev": "directus-extension build -w --no-minify",
"link": "directus-extension link",
"typecheck": "tsc --noEmit",
"test": "node --import tsx --test src/lib/*.test.ts",
"publish": "scp -r ./dist ./package.json land-nest:/home/oak/apps/directus/extensions/directus-extension-generate-image-previews/"
},
"devDependencies": {
"@directus/extensions-sdk": "13.0.1",
"@types/node": "^22.13.5",
"tsx": "^4.19.2",
"typescript": "^5.7.3",
"vue": "^3.5.13"
},
"dependencies": {
"object-hash": "^3.0.0"
}
}