import type { EndpointOptions } from '@navios/builder'; import type { ArgumentGetter, HandlerMetadata } from '@navios/core'; import type { FastifyRequest } from 'fastify'; import { InjectionToken } from '@navios/core'; import { FastifyEndpointAdapterService } from './endpoint-adapter.service.mjs'; /** * Injection token for the Fastify multipart adapter service. * * This token is used to inject the `FastifyMultipartAdapterService` instance * into the dependency injection container. */ export declare const FastifyMultipartAdapterToken: InjectionToken; /** * Adapter service for handling multipart/form-data requests in Fastify. * * This service extends `FastifyEndpointAdapterService` and provides specialized * handling for file uploads and multipart form data. It automatically parses * multipart streams, handles file uploads, converts files to File objects, * and validates the data against Zod schemas. * * @extends {FastifyEndpointAdapterService} * * @example * ```ts * // Used automatically when defining endpoints with @Multipart() * @Controller() * class UploadController { * @Multipart({ * method: 'POST', * url: '/upload', * requestSchema: uploadSchema, * }) * async uploadFile(data: UploadDto) { * // data contains parsed form fields and File objects * return { success: true } * } * } * ``` */ export declare class FastifyMultipartAdapterService extends FastifyEndpointAdapterService { /** * Creates argument getters for parsing multipart form data. * * This method creates an array of functions that extract and validate * data from multipart requests, including: * - Query parameters * - URL parameters * - Form fields and file uploads from multipart streams * * Files are converted to File objects, and form fields are parsed and * validated against the request schema. Supports arrays and nested objects. * * @param handlerMetadata - The handler metadata with schemas and configuration. * @returns An array of getter functions that populate request arguments. */ protected createArgumentGetters(handlerMetadata: HandlerMetadata): ArgumentGetter[]; /** * Provides Fastify schema information for multipart handlers. * * Creates a Fastify route schema object that includes query string and * response schemas. Note that multipart body schemas are handled separately * during request parsing. * * @param handlerMetadata - The handler metadata containing configuration and schemas. * @returns A Fastify route schema object. */ provideSchema(handlerMetadata: HandlerMetadata): Record; /** * Populates the request object with multipart data. * * Handles file uploads, form fields, arrays, and nested objects based on * the schema structure. * * @param structure - Schema structure analysis results. * @param part - Multipart part (file or value). * @param req - Request object to populate. * @private */ private populateRequest; /** * Analyzes the Zod schema shape to determine field types. * * Determines which fields are arrays, optional, or objects to properly * handle multipart parsing. * * @param shape - The Zod schema shape definition. * @returns An object mapping field names to their type information. * @private */ private analyzeSchema; } //# sourceMappingURL=multipart-adapter.service.d.mts.map