From 5458214ad9130f63fb918dd5b88578c09a866b29 Mon Sep 17 00:00:00 2001 From: Sebastian Frank Date: Thu, 29 Oct 2026 12:48:36 +0000 Subject: [PATCH] Schema: cache.image im Projekt und optionaler Asset-cachePath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - project.schema.json: cache.image.{path, autoCleanup.{maxAge,maxFiles,tempMaxAge}}; Server-only-Knöpfe (enabled, interval, Laufbudgets) sind bewusst nicht vorgesehen. - asset.schema.json: cachePath optional, ohne Pflicht-Verzeichnis, verweist auf cache.image.path als Default. - index.d.ts und Beispiel-YAML nachgezogen. --- examples/server/asset-image-processing.yml | 10 ++++-- index.d.ts | 9 ++++- schemas/config/asset.schema.json | 5 +-- schemas/config/project.schema.json | 38 ++++++++++++++++++++++ 4 files changed, 57 insertions(+), 5 deletions(-) diff --git a/examples/server/asset-image-processing.yml b/examples/server/asset-image-processing.yml index 064fa61..3997cd0 100644 --- a/examples/server/asset-image-processing.yml +++ b/examples/server/asset-image-processing.yml @@ -1,7 +1,13 @@ # Beispiel für einen Asset-Eintrag mit Bildverarbeitung (imageProcessing) # (tibi-server, ProjectConfig.assets[]) — validiert gegen schemas/config/asset.schema.json. -# Hinweis: cachePath muss ein existierendes Verzeichnis ausserhalb des Quellpfads -# sein; die Ajv-Validierung prueft nur Form und Wertebereiche, keine Dateisystempfade. +# Hinweis: cachePath ist optional. Explizit gesetzt ist er projektkontrolliert und +# folgt den normalen Pfad-Gates: relativ zur config.yml, ".." nur mit +# security.allowUpperPaths, absolut nur mit security.allowAbsolutePaths. +# Ohne cachePath gilt cache.image.path (Standard ../cache/image, +# operator-gesetzt, ".." dort ohne Flag erlaubt); ein Projekt kann ihn per +# cache.image.path überschreiben. +# Der Projekt-Namespace wird immer angehängt; das Verzeichnis wird beim ersten +# Render angelegt. Die Ajv-Validierung prueft nur Form und Wertebereiche. name: product-images path: ./media/products imageProcessing: diff --git a/index.d.ts b/index.d.ts index 2a6ab08..ee9f6d1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -421,7 +421,14 @@ declare global { /** Asset image processing block (`imageProcessing`) */ export interface AssetImageProcessingConfig { access: "public" - cachePath: string + /** + * Optional cache directory. An explicit value is project-controlled: + * relative to the project's config.yml, ".." needs + * security.allowUpperPaths, absolute needs security.allowAbsolutePaths. + * Omit to use cache.image.path (default ../cache/image). + * The project namespace is appended; the directory is created lazily. + */ + cachePath?: string allowOriginal?: boolean defaultFilter?: string allowedInputTypes?: Array<"image/jpeg" | "image/png" | "image/webp"> diff --git a/schemas/config/asset.schema.json b/schemas/config/asset.schema.json index 4a6dba7..eead2d2 100644 --- a/schemas/config/asset.schema.json +++ b/schemas/config/asset.schema.json @@ -25,7 +25,9 @@ ] }, "cachePath": { - "type": "string" + "type": "string", + "description": "Optional cache directory for filtered variants. An explicit value is project-controlled: relative to the project's config.yml, \"..\" needs security.allowUpperPaths, absolute needs security.allowAbsolutePaths. Omit it to use cache.image.path (default ../cache/image). The project namespace is appended and the directory is created lazily.", + "pattern": "^.+$" }, "allowOriginal": { "type": "boolean" @@ -73,7 +75,6 @@ }, "required": [ "access", - "cachePath", "imageFilter" ] } diff --git a/schemas/config/project.schema.json b/schemas/config/project.schema.json index 760973b..519d91b 100644 --- a/schemas/config/project.schema.json +++ b/schemas/config/project.schema.json @@ -345,6 +345,44 @@ "type": "string", "description": "Base directory for snapshot data, relative to configDir. Default: '{configDir}/snapshots'." }, + "cache": { + "type": "object", + "additionalProperties": false, + "description": "Per-project cache settings. Same key names as the server's cache.image block.", + "properties": { + "image": { + "type": "object", + "additionalProperties": false, + "description": "Derived image cache (filtered variants). Every value may only tighten cache.image.* of the server; path follows the usual security gates.", + "properties": { + "path": { + "type": "string", + "description": "Cache root for this project, relative to its config.yml. '..' needs security.allowUpperPaths, absolute needs security.allowAbsolutePaths." + }, + "autoCleanup": { + "type": "object", + "additionalProperties": false, + "description": "Retention limits; the switch, the schedule and the per-run I/O budget are server-controlled.", + "properties": { + "maxAge": { + "type": "string", + "description": "How long an unused variant may stay (Go duration, e.g. '168h'). Only shorter than cache.image.autoCleanup.maxAge." + }, + "maxFiles": { + "type": "integer", + "minimum": 1, + "description": "Maximum cache entries per cache directory. Only lower than cache.image.autoCleanup.maxFiles." + }, + "tempMaxAge": { + "type": "string", + "description": "Lifetime of abandoned .tmp-* files (Go duration). Only shorter than cache.image.autoCleanup.tempMaxAge." + } + } + } + } + } + } + }, "snapshots": { "type": "array", "description": "List of snapshot profiles for automated point-in-time backups.",