@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
73 lines • 4.04 kB
TypeScript
import type { DeliveryResult } from '../delivery.js';
import type { FocalPoint } from '../image_processor.js';
import { deliverRecord, imageOfRecord } from '../internal_symbols.js';
import { type AttachExistingInput, type AttachInput, type DeliverOptions, MediaLibrary, type MediaLibraryOptions, type MediaSignedUrlOptions, type StreamFileResult } from '../media_library.js';
import type { MediaRecord } from '../media_record.js';
import type { MediaListOptions, MediaListPage, MediaStore } from '../media_store.js';
import type { ResponsiveImage, ResponsiveImageOptions } from '../responsive_image.js';
import type { MediaStream } from '../streaming.js';
import { type MediaTenantClient } from './tenant_client.js';
/**
* Where a tenant's file URLs point:
* - `app` (default): this app's own delivery route (`delivery.path`, `media.access.deliveryRoute()`),
* which reads the bytes from the control plane. Same origin as the page, so a strict
* `img-src 'self'` holds, and it works when the control plane delivers by proxy.
* - `control-plane`: the storage URL the control plane hands out (signed or public). Needs a control
* plane that does not deliver by proxy.
*/
export type TenantUrls = 'app' | 'control-plane';
/** `30`, `'30'`, `'30s'`, `'5m'`, `'2h'`, `'1d'` → seconds. */
export declare function seconds(value: string | number): number;
/**
* The records of a tenant, read from the control plane. Only the reads the library makes go
* through it; every write is a call of its own on {@link TenantMediaLibrary}.
*/
export declare class RemoteMediaStore implements MediaStore {
private readonly client;
constructor(client: MediaTenantClient);
find(id: string): Promise<MediaRecord | null>;
listByOwner(ownerType: string, ownerId: string, collection?: string): Promise<MediaRecord[]>;
list(options?: MediaListOptions): Promise<MediaListPage>;
save(): Promise<MediaRecord>;
delete(): Promise<void>;
nextOrder(): Promise<number>;
}
/**
* `media.library` on a tenant: the same API, run on the control plane. Records, files and
* conversions live there; this app keeps its collection `access` rules, its delivery route and its
* signing secret.
*/
export declare class TenantMediaLibrary extends MediaLibrary {
#private;
constructor(options: MediaLibraryOptions, tenant: {
client: MediaTenantClient;
urls?: TenantUrls | undefined;
});
/** Upload the file to the control plane, which stores it and runs the collection's conversions. */
attach(input: AttachInput): Promise<MediaRecord>;
attachExisting(_input: AttachExistingInput): Promise<MediaRecord>;
rename(id: string, name: string): Promise<MediaRecord>;
delete(id: string): Promise<void>;
ensureConversion(id: string, conversionName: string): Promise<MediaRecord>;
/**
* The URL of a file: this app's delivery route (`urls: 'app'`, signed when `delivery.signing` is
* set), or the control plane's storage URL (`urls: 'control-plane'`).
*/
url(id: string, conversion?: string): Promise<string>;
/** A time-limited storage URL, signed by the control plane (not by proxy). */
signedUrl(id: string, expiresIn: string | number, options?: MediaSignedUrlOptions): Promise<string>;
deliver(id: string, options?: DeliverOptions): Promise<DeliveryResult>;
/** @internal */
[deliverRecord](record: MediaRecord, options?: DeliverOptions): Promise<DeliveryResult>;
/**
* The responsive-image props, computed by the control plane from its collection presets; each
* URL is this app's (`urls: 'app'`) or the control plane's.
* @internal
*/
[imageOfRecord](record: MediaRecord, options?: ResponsiveImageOptions): Promise<ResponsiveImage>;
transform(_id: string, transformerName: string): Promise<MediaRecord>;
setFocalPoint(_id: string, _point: FocalPoint | null): Promise<MediaRecord>;
stream(): Promise<MediaStream>;
streamFile(): Promise<StreamFileResult>;
}
//# sourceMappingURL=tenant_library.d.ts.map