imajin/services/imajin-processing/client/dist/index.d.mts

84 lines
3.9 KiB
TypeScript

import { HealthResponse, AllowedMimeType, ProcessOperation, FamilyName, ProcessResponse, SanitizeOptions, SanitizeResponse, ResizeMode, ImageFormat, ResizeResponse, ThumbnailResponse, OptimizationPreset, DerivativesResponse, SingleDerivativeResponse, MasterResponse, ConvertResponse, MetadataResponse } from '@lilith/imajin-processing-types';
export { AllowedMimeType, ConvertOptions, ConvertRequest, ConvertResponse, DerivativeResult, DerivativesOptions, DerivativesRequest, DerivativesResponse, FamilyName, HealthResponse, IMAGE_MAGIC_BYTES, ImageFormat, ImageMetadata, ImageSize, ImageValidationResult, MasterRequest, MasterResponse, MetadataRequest, MetadataResponse, OPTIMIZATION_PRESETS, OptimizationPreset, ProcessOperation, ProcessRequest, ProcessResponse, ProcessedImage, ResizeMode, ResizeOptions, ResizeRequest, ResizeResponse, SanitizeOptions, SanitizeRequest, SanitizeResponse, SingleDerivativeRequest, SingleDerivativeResponse, ThumbnailRequest, ThumbnailResponse, detectMimeTypeFromBytes, validateImageBytes, validateMagicBytes } from '@lilith/imajin-processing-types';
/**
* Image Processing Client
*
* HTTP client for the image processing service.
*/
interface ImageProcessingClientConfig {
/** Base URL of the image processing service */
baseUrl: string;
/** Request timeout in milliseconds (default: 60000) */
timeout?: number;
}
declare class ImageProcessingError extends Error {
readonly statusCode?: number | undefined;
readonly code?: string | undefined;
constructor(message: string, statusCode?: number | undefined, code?: string | undefined);
}
declare class ImageProcessingClient {
private readonly baseUrl;
private readonly timeout;
constructor(config: ImageProcessingClientConfig);
private fetch;
/**
* Check service health.
*/
health(): Promise<HealthResponse>;
/**
* Process an image through a pipeline of operations.
* Operations are executed sequentially in the order specified.
*
* @param image - Base64-encoded image data
* @param mimeType - MIME type of the image
* @param operations - Array of operations to apply
* @param family - Image family (required if 'derivatives' operation is included)
*/
process(image: string, mimeType: AllowedMimeType, operations: ProcessOperation[], family?: FamilyName): Promise<ProcessResponse>;
/**
* Sanitize an image by re-encoding it.
* Strips EXIF data and potential malicious content.
*/
sanitize(image: string, mimeType: AllowedMimeType, options?: SanitizeOptions): Promise<SanitizeResponse>;
/**
* Resize an image with the specified mode.
*/
resize(image: string, width: number, height: number, options?: {
mode?: ResizeMode;
format?: ImageFormat;
quality?: number;
background?: string;
}): Promise<ResizeResponse>;
/**
* Generate a thumbnail.
*/
thumbnail(image: string, size?: number, quality?: number): Promise<ThumbnailResponse>;
/**
* Generate all derivatives for a family.
*/
derivatives(image: string, family: FamilyName, preset?: OptimizationPreset): Promise<DerivativesResponse>;
/**
* Clip a single derivative from an image.
*/
singleDerivative(image: string, width: number, height: number, preset?: OptimizationPreset): Promise<SingleDerivativeResponse>;
/**
* Prepare a master image for a family.
*/
master(image: string, family: FamilyName, preset?: OptimizationPreset): Promise<MasterResponse>;
/**
* Convert an image to a different format.
*/
convert(image: string, format: ImageFormat, quality?: number): Promise<ConvertResponse>;
/**
* Get image metadata.
*/
metadata(image: string): Promise<MetadataResponse>;
}
/**
* Create a client for local development.
*/
declare function createLocalClient(port?: number): ImageProcessingClient;
export { ImageProcessingClient, type ImageProcessingClientConfig, ImageProcessingError, createLocalClient };