Skip to content

file-derivatives

Declares the derivativeRenderer extension point. ctx.services.derivatives.variant(fileRefId, spec, name) derives a variant of a tracked FileRef the first time it’s requested and reuses the stored result afterwards (derive-on-first-use, keyed by a hash of the spec). Mount at least one derivatives-* renderer feature alongside this one — without a registered renderer for the FileRef’s MIME type, every variant(...) call throws. Also declares the derivativePublicPredicate extension point (r.useExtension(EXT_DERIVATIVE_PUBLIC_PREDICATE, '<entityType>', { isPublic })) and, when createFileDerivativesFeature({resolveApexTenant}) is passed a host-resolver, mounts an anonymous GET {basePath}/:fileRefId/:variant route that serves any variant name the FileRef’s field declared in its variants for a FileRef whose entityType has a registered predicate returning true — default-deny (404) otherwise, same as an unknown FileRef or an undeclared variant name. The route’s only rate-limit (per: "ip") depends on the server’s trustedProxyHops matching the deployment’s actual reverse-proxy count — at the default 0 it ignores x-forwarded-for entirely, so every caller shares one bucket until that’s configured. publicTenantResolution: "fileRef" keeps resolveApexTenant as the host gate but reads the variant from the FileRef row’s own tenant instead of the host’s, so one shared platform host serves every tenant’s public variants — each FileRef-tenant’s own isPublic predicate still default-denies. Also declares the derivativeOverlayResolver extension point (r.useExtension(EXT_DERIVATIVE_OVERLAY_RESOLVER, '<entityType>', { resolve })), used to turn a variant’s overlays[].dataToken into the actual QR payload for that FileRef’s entityType before the variant is rendered — a variant declaring a qr overlay throws at request-time if no resolver is registered for the FileRef’s entityType.

What this feature needs to run (Requires).

flowchart TB
  n_file_derivatives["file-derivatives"]
  subgraph how_reqs["Requires"]
    n_file_foundation["file-foundation"]
    n_files["files"]
  end
  n_file_foundation --> n_file_derivatives
  n_files --> n_file_derivatives