import { RpcMethod } from './commonTypes'; export type MediaFilesService_List = RpcMethod; export type MediaFilesService_CreateVariant = RpcMethod; export type MediaFilesService_Delete = RpcMethod; export type MediaFilesService_GetUsage = RpcMethod; export interface MediaFilesService { /** Lists an application's media image files newest-first, with paging and an optional filename substring search. Returns only originals by default; pass parent_uuid to instead list the cropped variants of that original. */ List: MediaFilesService_List; /** Creates a cropped variant of an existing original image (by uuid) for the given aspect ratio, storing it in S3 as a child of the original. Idempotent per original and ratio: calling again with the same original and ratio returns the existing variant instead of duplicating it. */ CreateVariant: MediaFilesService_CreateVariant; /** Deletes a media file by uuid, removing its database record and S3 objects; deleting an original cascades to all of its cropped variants, while deleting a variant removes only that variant. Not reversible. */ Delete: MediaFilesService_Delete; /** Returns an application's media storage footprint: count of original files, total file count including cropped variants, and total bytes stored in S3 (originals, variants and thumbnails). Use to check or report media quota usage for an application code. */ GetUsage: MediaFilesService_GetUsage; } /** AspectRatio enumerates the supported aspect ratios for image variants. */ export type AspectRatio = 'ASPECT_RATIO_UNSPECIFIED' | 'ASPECT_RATIO_1_1' | 'ASPECT_RATIO_4_3' | 'ASPECT_RATIO_3_2' | 'ASPECT_RATIO_4_5' | 'ASPECT_RATIO_5_4' | 'ASPECT_RATIO_16_9' | 'ASPECT_RATIO_16_10' | 'ASPECT_RATIO_21_9' | 'ASPECT_RATIO_9_16'; export type CreateVariantRequest_size_width = { type: 'width'; data: number; }; export type CreateVariantRequest_size_height = { type: 'height'; data: number; }; export type CreateVariantRequest_size = CreateVariantRequest_size_width | CreateVariantRequest_size_height; export type CreateVariantRequest = { /** Application code (format XXXXX-XXXXX) that owns the original image. */ application?: string; /** uuid of the existing original image to derive the variant from. */ uuid?: string; ratio?: AspectRatio; /** * quality is the JPEG encode quality (1-100). Applies only when the variant * is encoded as JPEG (i.e. the original is a JPEG); ignored otherwise. */ quality?: number; size: CreateVariantRequest_size; }; export type CreateVariantResponse = { file: MediaFile; }; export type UploadMediaFileRequest = { /** Application code (format XXXXX-XXXXX) to store the image under. */ application: string; /** Original filename; defaults to "upload_" when empty. */ filename: string; /** Raw image bytes to upload. */ data: string; /** MIME type of the image (image/jpeg, image/png, image/gif, image/webp); auto-detected from the bytes when empty. */ mimeType: string; description?: string; }; export type UploadMediaFileResponse = { file: MediaFile; }; export type ListMediaFilesRequest = { /** Application code (format XXXXX-XXXXX) whose media files to list. */ application?: string; page?: number; perPage?: number; /** * parent_uuid filters the listing: when set, returns the variants of that * original image; when empty, returns only originals (no variants). */ parentUuid?: string; /** * search_by_name filters the listing to files whose filename contains this * substring (case-insensitive, like %search_by_name%). Empty means no filter. */ searchByName?: string; /** * extensions keeps only files whose stored path ends with one of these image * extensions ("jpg" or ".jpg", case-insensitive). Empty means no filter. * Callers that can only consume some formats (MMS attachments take jpg/jpeg/png/gif) * must filter here rather than client-side, so page size and total stay honest. */ extensions?: string[]; }; export type ListMediaFilesResponse = { files: MediaFile[]; page: number; perPage: number; total: number; }; export type DeleteMediaFileRequest = { /** Application code (format XXXXX-XXXXX) that owns the file. */ application?: string; /** uuid of the media file to delete (an original cascades to its variants). */ uuid?: string; }; export type DeleteMediaFileResponse = {}; export type GetMediaFilesUsageRequest = { /** Application code (format XXXXX-XXXXX) whose media storage usage to compute. */ application?: string; }; export type GetMediaFilesUsageResponse = { /** originals_count is the number of original files (no parent). */ originalsCount: number; /** total_count is the number of files, including cropped variants. */ totalCount: number; /** * total_size is the total bytes stored in S3 for the application — * originals, variants and thumbnails. */ totalSize: number; }; export type MediaFile_ImageMeta = { width: number; height: number; thumbnailUrl: string; thumbnailWidth: number; thumbnailHeight: number; /** ratio is the aspect ratio of a variant (e.g. "16:9"), empty for originals. */ ratio: string; }; export type MediaFile_meta_imageMeta = { type: 'imageMeta'; data: MediaFile_ImageMeta; }; export type MediaFile_meta = MediaFile_meta_imageMeta; export type MediaFile = { uuid: string; filename: string; url: string; fileSize: number; mimeType: string; createdAt: Date; description?: string; /** parent_uuid is set on variants and points to the original image's uuid. */ parentUuid?: string; meta: MediaFile_meta; };