import { NestInterceptor, ExecutionContext, CallHandler } from "@nestjs/common"; import { Observable } from "rxjs"; import { IFileOptions } from "../interfaces/file.interface"; /** * Interceptor to handle file uploads using Busboy. */ export declare class FormdataInterceptor implements NestInterceptor { private readonly fileOptions?; private readonly arrayRegexPattern; private readonly nestedRegexPattern; private httpRequest; private busboy; /** * Constructs a new instance of the FormdataInterceptor class. * @param fileOptions - Optional configuration options for file handling. */ constructor(fileOptions?: IFileOptions); /** * Intercepts the request to handle file uploads if the content type is multipart/form-data. * @param context - The execution context. * @param next - The next call handler. * @returns An Observable that processes the file upload. */ intercept(context: ExecutionContext, next: CallHandler): Promise>; /** * Handles multipart/form-data file uploads. * @param context - The execution context. * @param next - The next call handler. * @param request - The HTTP request. * @param customFileName - Optional function to customize file names. * @param fileSaver - Optional file saver implementation. * @returns An Observable that processes the file upload. */ private handleMultipartFormData; /** * Cleans up the resources used by the `busboy` instance and removes all event listeners. */ private handleDone; /** * assign save file strategy * * @param fileSaver - file saver strategy * @param context - The execution context. */ private assignFile; /** * Handles a file field by adding FileData to the target object. * Automatically uses MultipleFileData for array fields or multiple files with same name. * @param target - The target object to set the field value. * @param fieldName - The name of the field. * @param fileData - The FileData to add. */ private handleFileField; /** * Handles a field by setting its value in the target object, supporting nested fields and arrays. * @param target - The target object to set the field value. * @param fieldName - The name of the field. * @param value - The value to set. */ private handleField; /** * Sets a nested value in an object, supporting nested fields and arrays. * @param obj - The object to set the nested value in. * @param keys - The keys representing the nested path. * @param value - The value to set. * @param isArray - Whether the field is an array. */ private setNestedValue; /** * Assigns a value to the specified key in an object, supporting arrays. * @param obj - The object to set the value in. * @param key - The key to set the value for. * @param value - The value to set. * @param isArray - Whether the field is an array. */ private assignValue; /** * Assigns a single value or array value to the specified key in an object. * @param obj - The object to set the value in. * @param key - The key to set the value for. * @param value - The value to set. */ private assignSingleValue; /** * Assigns a value to an array at the specified key in an object. * @param obj - The object to set the value in. * @param key - The key to set the value for. * @param value - The value to set. */ private assignArrayValue; }