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

90 lines • 4.22 kB
import type { MediaConversion, MediaRecord } from '../media_record.js'; /** * The wire contract between a media control plane (the Hub) and its tenants (the apps). Both sides * import it from here, so they cannot drift. */ /** The resource indicator (RFC 8707) every media control plane answers for: the `aud` of tenant tokens. */ export declare const MEDIA_RESOURCE = "urn:agora:media"; /** What each control-plane endpoint requires in the token's `capabilities`. */ export declare const MEDIA_SCOPES: { /** Read records, their bytes and their URLs (and account files). */ readonly read: 'media:read'; /** Add, rename and delete records. */ readonly write: 'media:write'; }; /** Route prefix of the control-plane API. */ export declare const DEFAULT_CONTROL_PLANE_PREFIX = "/_media"; /** Where a media topology runs. */ export type MediaTopology = 'standalone' | 'control-plane' | 'tenant'; /** A partition (the tenant app's name, from its token): what an app key may be everywhere. */ export declare const PARTITION_PATTERN: RegExp; /** An owner type a tenant may use: a model name, no `/`. */ export declare const OWNER_TYPE_PATTERN: RegExp; /** An owner id a tenant may use: a primary key, no `/`, never `.` or `..`. */ export declare const OWNER_ID_PATTERN: RegExp; /** A collection or conversion name on the wire. */ export declare const NAME_PATTERN: RegExp; /** * The owner type a tenant's record is stored under on the control plane: `<partition>/<ownerType>`. * Every lookup by owner goes through it, so two apps' `User 42` never meet, and the storage keys of * an app's files start with `<partition>/`. */ export declare function partitionOwnerType(partition: string, ownerType: string): string; /** Whether a stored record belongs to `partition`. */ export declare function inPartition(partition: string, record: Pick<MediaRecord, 'ownerType'>): boolean; /** A stored record as its tenant sees it: the owner type without the partition. */ export declare function withoutPartition(partition: string, record: MediaRecord): MediaRecord; /** A media record as JSON. */ export interface WireMediaRecord { id: string; ownerType: string; ownerId: string; collection: string; name: string; fileName: string; mimeType: string; size: number; disk: string; path: string; order: number; customProperties: Record<string, unknown>; conversions: Record<string, MediaConversion>; createdAt: string; updatedAt: string; } /** A record for the wire. The tenant never sees the control plane's tenant (organization) column. */ export declare function toWireRecord(record: MediaRecord): WireMediaRecord; /** A record from the wire, with its dates revived. Throws on a body that is not a record. */ export declare function fromWireRecord(value: unknown): MediaRecord; /** * Strong ETag of one rendition of a record: changes with the record (`updatedAt`) and differs per * conversion and size. */ export declare function mediaEtag(record: Pick<MediaRecord, 'id' | 'updatedAt'>, rendition?: { conversion?: string | undefined; width?: number | string | undefined; quality?: number | string | undefined; }): string; /** Largest width a resize request may ask for (the library's own ceiling for signed URLs). */ export declare const MAX_RENDITION_WIDTH = 8192; /** * The rendition query of a file read (`conversion`, `w`, `q`), validated: a conversion name, a * whole width in `1..8192`, a whole quality in `1..100`. Throws a `TypeError` naming the bad one. */ export declare function readRendition(query: { conversion?: string | undefined; width?: string | undefined; quality?: string | undefined; }): { conversion?: string; width?: string; quality?: string; }; /** `If-None-Match` matches `etag`? Accepts a list and the weak form. */ export declare function etagMatches(ifNoneMatch: string | undefined, etag: string): boolean; /** * Stands for "the URL of this conversion" in a `ResponsiveImage` the control plane computes for a * tenant that serves the files itself: the tenant swaps each for its own URL. */ export declare const IMAGE_URL_TOKEN = "agora-media-url:"; //# sourceMappingURL=protocol.d.ts.map