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

95 lines • 3.52 kB
import type { HttpContext } from '@adonisjs/core/http'; import type { DashboardService } from './service.js'; /** The container binding the dev-tools hub lives at. */ export declare const DEV_TOOLS_BINDING = "agora.devTools"; /** The hub a lib registers its developer tools into. */ export interface DevToolsHub { readonly version: 1; register(lib: DevToolsLib): void; } /** One lib's tools and the gate that decides who may use them. */ export interface DevToolsLib { lib: string; title: string; authorize(ctx: HttpContext): Promise<DevToolsDecision>; tools: DevTool[]; } /** What a lib's `authorize` answers: the console decision. */ export type DevToolsDecision = { allowed: true; } | { allowed: false; reason: 'unauthenticated' | 'forbidden'; redirectTo?: string; }; /** One developer tool. */ export interface DevTool { name: string; kind: 'read' | 'action'; description: string; input: DevToolInputSchema; destructive?: boolean; available?(): boolean | Promise<boolean>; run(input: Record<string, unknown>, call: DevToolCall): Promise<unknown>; } /** What a tool's `run` receives besides its input. */ export interface DevToolCall { ctx: HttpContext; caller: DevToolsCaller; limits: { maxRows: number; maxBytes: number; }; } /** Who is calling. Never a token value. */ export interface DevToolsCaller { id: string; via: 'token' | 'session' | 'open'; } /** One property of a {@link DevToolInputSchema}. */ export interface DevToolInputProperty { type: 'string' | 'number' | 'integer' | 'boolean' | 'array'; description?: string; enum?: readonly string[]; items?: { type: 'string'; }; minimum?: number; maximum?: number; } /** An object of scalar / enum / array-of-string properties. */ export interface DevToolInputSchema { type: 'object'; properties: Record<string, DevToolInputProperty>; required?: string[]; } /** What {@link mediaDevTools} needs from the console. */ export interface MediaDevToolsOptions { /** * The console's service, built per call for the request being served (the same one the console's * JSON API uses, so its disk list and `actions` switch apply). */ service: (ctx: HttpContext) => Promise<DashboardService>; /** Whether the console's mutating actions are on (`actions` in `config/media_dashboard.ts`). */ actions: boolean; } /** `media_delete_objects` deletes at most this many keys per call. */ export declare const MAX_DELETE_KEYS = 100; /** * The media console's developer tools: the same {@link DashboardService} the console's JSON API runs, * under `media_*` names. Signed URLs never leave: object and record reads drop every `url`. Reads * are listed by default; the two actions (abort an upload, delete objects) only when the app opts in * on the dev endpoint AND the console's own `actions` switch is on. */ export declare function mediaDevTools(options: MediaDevToolsOptions): DevTool[]; /** * Register the media console's tools into the app's dev-tools hub, when one is bound (the app * registered `@adonis-agora/agent/mcp_provider`). Returns whether it registered. */ export declare function registerMediaDevTools(container: { hasBinding(binding: string): boolean; make(binding: string): Promise<unknown>; }, options: MediaDevToolsOptions & { authorize: (ctx: HttpContext) => Promise<DevToolsDecision>; }): Promise<boolean>; //# sourceMappingURL=dev_tools.d.ts.map