@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
64 lines • 2.77 kB
TypeScript
import type { ApplicationService } from '@adonisjs/core/types';
import type { UploadSessionStore } from '../resumable_upload.js';
/**
* Runtime context an {@link UploadSessionStoreFactory} thunk receives when the media provider builds
* the configured session store at boot. Carries the booted application so a driver can resolve a
* peer's service (the Lucid `db`).
*/
export interface UploadSessionStoreContext {
app: ApplicationService;
/** Media's `tenancy` is on: the store reads and writes the sessions' `tenant_id`. */
tenancy?: boolean;
}
/**
* A configured resumable session store: a lazy thunk the media provider calls at boot to build the
* {@link UploadSessionStore}. Each factory imports its peer (`@adonisjs/lucid`) inside the thunk, so
* the driver only loads when actually selected — keeping that package optional.
*/
export type UploadSessionStoreFactory = (ctx: UploadSessionStoreContext) => Promise<UploadSessionStore>;
/** Options for the Lucid-backed resumable session store. */
export interface LucidUploadSessionStoreConfig {
/** Lucid connection name to use. Defaults to the `Database` default connection. */
connection?: string;
/** Sessions table name. Default `media_upload_sessions`. */
table?: string;
/** Parts side-index table name. Default `media_upload_parts`. */
partsTable?: string;
}
/**
* The resumable session-store factory namespace used in `config/media.ts` (mirrors {@link stores}):
*
* ```ts
* import { defineConfig, uploadSessions } from '@adonis-agora/media'
*
* export default defineConfig({
* uploads: {
* resumable: {
* store: 'lucid',
* stores: {
* memory: uploadSessions.memory(),
* lucid: uploadSessions.lucid({ connection: 'pg' }),
* },
* routes: { enabled: true },
* },
* },
* })
* ```
*/
export declare const uploadSessions: {
/** In-memory session store — single-process, non-durable. Handy for tests and scratch apps. */
memory(): UploadSessionStoreFactory;
/** Persist resumable sessions in SQL via `@adonisjs/lucid`. */
lucid(config?: LucidUploadSessionStoreConfig): UploadSessionStoreFactory;
};
/**
* Build the resumable session store selected by `config.store` from the `config.stores` map. A named
* store with no matching factory THROWS {@link UploadSessionStoreNotConfiguredError} (a non-durable
* fallback would silently lose resumable state); only the zero-config path (no `store` named)
* resolves to the in-memory store.
*/
export declare function resolveUploadSessionStore(config: {
store?: string;
stores?: Record<string, UploadSessionStoreFactory>;
}, ctx: UploadSessionStoreContext): Promise<UploadSessionStore>;
//# sourceMappingURL=factory.d.ts.map