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

63 lines • 3.51 kB
/** * What media runs on, for telescope's Architecture page ("media: media files → S3 hub-avatars"). * Telescope walks `app.config.get('media')` after boot and reads, on every object or function it * meets, the uses stored under the global symbol {@link STACK_DESCRIPTOR}. Media does not depend on * telescope: the symbol is global, and the helper below is all there is to it. * * Never put a key, a secret or a URL with credentials in a `label`; `host` is hashed, never sent. */ import type { MediaConfig } from './define_config.js'; /** The symbol telescope reads a factory's {@link StackUse} list from. */ export declare const STACK_DESCRIPTOR: unique symbol; /** One thing media uses: a database, a Redis server, a bucket, a Drive disk. */ export interface StackUse { /** `postgres`, `redis`, `s3`, `r2`, `gcs`, `minio`, `drive`, … */ tech: string; /** The Lucid or Redis connection it goes through. */ connection?: string; /** What it is for, in a few words. */ purpose?: string; /** For a bucket or a disk: its name. */ label?: string; /** Tells two buckets of the same name apart (hashed by telescope, never sent). */ host?: string; } /** Attach `use` to `target` (non-enumerable). A frozen target is left as is. Returns `target`. */ export declare function describeStackUse<T extends object>(target: T, use: StackUse | StackUse[]): T; /** The uses already on `target`, if any. */ export declare function readStackUses(target: unknown): StackUse[]; /** * Marks a `stores.lucid()` / `uploadSessions.lucid()` factory with its connection. Not the stack * symbol itself: an unselected store must not show up, so the provider describes only the * selected one, at boot, filling in the default connection. */ export declare const LUCID_STORE: unique symbol; /** Tag a Lucid store factory (see {@link LUCID_STORE}). */ export declare function markLucidStore<T extends object>(target: T, connection: string | undefined): T; /** * The tech of an S3-compatible endpoint: `r2`, `gcs`, `minio`, or `s3` (AWS, or anything else * speaking the S3 API). */ export declare function s3EndpointTech(endpoint: string | undefined): string; /** The hostname of an endpoint URL, without credentials, port or path. */ export declare function endpointHost(endpoint: string | undefined): string | undefined; /** What the provider knows at boot that the config file does not say. */ export interface MediaStackContext { /** The disk media writes to when `config.disk` is unset (Drive's default). */ defaultDisk?: string; /** `database.connection`: the Lucid connection a store without `connection` uses. */ defaultDbConnection?: string; /** Lucid connection name → its `client` (`pg`, `mysql2`, …), to name the tech. */ dbClients?: Record<string, string>; /** `redis.connection`: the Redis connection `consoleCommands` uses without one. */ defaultRedisConnection?: string; } /** * Everything `config/media.ts` selects, as stack uses: the Drive disks media writes to (a disk * from `config.disks` describes itself on its factory), the selected Lucid stores and the Redis * connection of `consoleCommands`. */ export declare function mediaStackUses(config: MediaConfig, ctx?: MediaStackContext): StackUse[]; /** Put {@link mediaStackUses} on the `media` config object itself, where telescope reads it. */ export declare function describeMediaConfig(config: MediaConfig, ctx?: MediaStackContext): void; //# sourceMappingURL=stack.d.ts.map