UNPKG

@adonis-agora/media

Version:

Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), pluggable content transformers (HLS video via mediabunny, metadata probe, image blur-up placeholder), and column attachments, a

64 lines • 3.32 kB
import type { MediaCollectionAccess } from './access.js'; import type { ConversionPreset } from './image_processor.js'; import type { Transformer } from './transformer.js'; /** Widths a `responsive: true` collection generates (those below the original's width). */ export declare const DEFAULT_RESPONSIVE_WIDTHS: readonly number[]; /** `responsive` options. */ export interface ResponsiveImagesConfig { /** Widths to generate. Default {@link DEFAULT_RESPONSIVE_WIDTHS}. */ widths?: readonly number[]; /** Output format. Default `webp`. */ format?: ConversionPreset['format']; /** Output quality. */ quality?: number; } export interface MediaCollectionConfig { name: string; /** Single-file collection: attaching replaces any existing media. */ single?: boolean; /** Target disk for this collection (defaults to the storage default disk). */ disk?: string; /** Allowed MIME types; when set, other types are rejected on attach. */ acceptsMimeTypes?: string[]; /** Image conversion presets available for this collection. */ conversions?: ConversionPreset[]; /** * Content transformers available for this collection (e.g. `transformers.video()`). Each produces * a named entry in `record.conversions`, so transformer names and preset names share one * namespace — a collision throws {@link TransformerConflictError} at construction. */ transformers?: Transformer[]; /** * Responsive images without hand-written presets (spatie's `withResponsiveImages()`): eager * presets `responsive-<width>` at each width below the original's (wider ones are skipped, not * stored as same-size copies), plus `transformers.placeholder()` if the collection has none — * everything `media.library.image(id)` needs for a `srcset`, the intrinsic size and the blur-up. */ responsive?: boolean | ResponsiveImagesConfig; /** * Strip the original's metadata on attach — EXIF (a phone photo carries the GPS position where * it was taken, the device, the time), XMP and IPTC — keeping its format, colour profile and * orientation (baked into the pixels). Conversions never carry metadata; this covers the * original, which is otherwise served exactly as uploaded. The original is downloaded and * rewritten (lossy formats re-encoded at high quality), so it costs a round trip per attach — * also on `attachExisting`. Only images with something to strip are rewritten. */ stripMetadata?: boolean; /** * Who may read files of this collection and who may put files into it — applied by * `media.access` (its `deliveryRoute()`, `image()`, `authorize()`). `'public'` allows everyone; * an absent rule denies. Build rules with `authorizers` (and the authkit/authz integrations): * * ```ts * { name: 'avatar', access: { read: authorizers.owner(), write: authorizers.authenticated() } } * ``` */ access?: MediaCollectionAccess; } export declare class MediaCollectionRegistry { private readonly map; constructor(collections?: readonly MediaCollectionConfig[]); /** Registered config for a collection, or a permissive default. */ get(name: string): MediaCollectionConfig; } //# sourceMappingURL=media_collection.d.ts.map