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

49 lines • 2.66 kB
import type { HttpContext } from '@adonisjs/core/http'; /** Who is signed in, as the sidebar footer shows it. */ export interface ConsoleViewer { /** Main line: a name or an email. */ label: string; email?: string; /** Small caps line under it (`admin`). */ role?: string; } /** How the footer signs out: a POST form (with the CSRF token) or a plain link. */ export type ConsoleSignOut = { action: string; csrfToken?: string; } | { href: string; }; /** The `signOut` config option: a POST action path, `{ action }`, `{ href }`, or `false` for none. */ export type SignOutOption = string | { action: string; } | { href: string; } | false; /** The `viewer` config hook: return the viewer, or `null`/`undefined` for no user row. */ export type ViewerHook = (ctx: HttpContext) => ConsoleViewer | null | undefined | Promise<ConsoleViewer | null | undefined>; /** The one role the footer shows: the first admin-like one (`ADMIN`, `org_admin`), else the first. */ export declare function pickRole(names: readonly string[]): string | undefined; /** * A viewer from any user-ish object: `fullName` / `name` / `email` for the label, `email`, and one * role from `role` / `roles` / `globalRoles` plus `extraRoles` (an admin-like one first, else the * first). `undefined` when nothing usable is there. */ export declare function viewerFromUser(user: unknown, extraRoles?: readonly string[]): ConsoleViewer | undefined; /** * The viewer for this request: the host's `viewer(ctx)` hook when configured (a throw or an empty * answer means no user row), else a structural read of `ctx.auth?.user` — only when the request is * already authenticated; it never triggers an authentication. The fallback's role also looks at * authkit's per-request identity (`ctx.authkit`, its `globalRoles`) once a user is there. */ export declare function resolveViewer(ctx: HttpContext, hook: ViewerHook | null | undefined): Promise<ConsoleViewer | undefined>; /** The request's CSRF token when `@adonisjs/shield` (or anything like it) put one on the request. */ export declare function csrfTokenOf(ctx: HttpContext): string | undefined; /** * The sign-out the footer offers: the host's `signOut` option when set (`false` = none), else the * one an account console (authkit) announced on the `agora.consoles` registry, else none. Only * same-origin paths are ever emitted. A POST action carries the request's CSRF token when there is * one. */ export declare function resolveSignOut(ctx: HttpContext, configured: SignOutOption | null | undefined, registry: unknown): ConsoleSignOut | undefined; //# sourceMappingURL=console_shell.d.ts.map