import { L as LucidErrorData, g as ErrorResult, R as ResponseBody, P as Permission, h as ControllerSchema, i as RouteController, S as ServiceFn, j as ServiceWrapperConfig, k as ServiceContext, m as ServiceResponse } from './types-CPsn9Vky.js';
import z from 'zod';
import { FastifyRequest, FastifyInstance, FastifySchema } from 'fastify';
import 'kysely';
import 'fs';
import 'stream';
import 'kysely/helpers/sqlite';
import 'node:stream';
import 'vite';

/**
 * The LucidAPIError class should be used to throw errors within the API request lifecycle. This will be caught by Fastify's error handler and will return a formatted error response. If the error is a Zod error, it will be formatted into a more readable format.
 * @class
 * @extends Error
 * @param {LucidErrorData} error
 * @returns {void}
 * @example
 * throw new LucidAPIError({
 *    type: "basic",
 *    name: "Fetch User Error",
 *    message: "Error while fetching user data",
 *    status: 500,
 * });
 * @example
 * throw new LucidAPIError({
 *    type: "validation",
 *    name: "Validation Error",
 *    message: "Validation error occurred",
 *    status: 400,
 *    errorResponse: {
 *        body: {
 *            email: {
 *                code: "invalid_email",
 *                message: "Invalid email address",
 *            },
 *        },
 *    },
 * });
 */
declare class LucidAPIError extends Error {
    error: LucidErrorData;
    constructor(error: LucidErrorData);
    static formatZodErrors(error: z.core.$ZodIssue[]): ErrorResult;
}

interface BuildResponseParams {
    data: unknown;
    pagination?: {
        count: number;
        page: number;
        perPage: number;
    };
}
type FormatAPIResponse = (request: FastifyRequest, params: BuildResponseParams) => ResponseBody;
declare const formatAPIResponse: FormatAPIResponse;

type Route = <ParamsT extends z.ZodType | undefined, BodyT extends z.ZodType | undefined, QueryT extends z.ZodType | undefined, QueryFT extends z.ZodType | undefined>(fastify: FastifyInstance, opts: {
    method: "get" | "post" | "put" | "delete" | "patch";
    url: string;
    permissions?: Permission[];
    middleware?: {
        authenticate?: boolean;
        validateCSRF?: boolean;
        contentLocale?: boolean;
        clientAuthentication?: boolean;
    };
    zodSchema?: ControllerSchema;
    swaggerSchema?: Record<string, unknown>;
    bodyLimit?: number;
    controller: RouteController<ParamsT, BodyT, QueryT, QueryFT>;
}) => void;
declare const route: Route;

declare const serviceWrapper: <T extends unknown[], R>(fn: ServiceFn<T, R>, wrapperConfig: ServiceWrapperConfig) => (service: ServiceContext, ...args: T) => ServiceResponse<R>;

declare const swaggerResponse: (config: {
    schema?: unknown;
    paginated?: boolean;
    noProperties?: boolean;
}) => FastifySchema["response"];

interface SwaggerHeaders {
    csrf?: boolean;
    contentLocale?: boolean;
    clientKey?: boolean;
    authorization?: boolean;
}
/**
 * Used to construct headers JSON schema for Swagger
 */
declare const swaggerHeaders: (headers: SwaggerHeaders) => {
    type: string;
    properties: {
        _csrf?: {
            type: string;
            description: string;
            example?: string;
        };
        "lucid-content-locale"?: {
            type: string;
            description: string;
            example?: string;
        };
        "lucid-client-key"?: {
            type: string;
            description: string;
            example?: string;
        };
        Authorization?: {
            type: string;
            description: string;
            example?: string;
        };
    };
    required: string[];
};

declare const refs: {
    readonly defaultError: "DefaultError";
};

export { LucidAPIError, formatAPIResponse, route, serviceWrapper, swaggerHeaders, refs as swaggerRefs, swaggerResponse };
