/// import { FastifyPluginCallback, FastifyReply, FastifyRequest, HTTPMethods, RawReplyDefaultExpression, RawServerBase, RequestGenericInterface, RouteGenericInterface } from 'fastify' import { Agent, AgentOptions, IncomingHttpHeaders, IncomingMessage, RequestOptions, } from 'node:http' import { ClientSessionOptions, ClientSessionRequestOptions, IncomingHttpHeaders as Http2IncomingHttpHeaders, SecureClientSessionOptions, } from 'node:http2' import { Agent as SecureAgent, AgentOptions as SecureAgentOptions, RequestOptions as SecureRequestOptions } from 'node:https' import { Pool, ProxyAgent, Dispatcher } from 'undici' declare module 'fastify' { interface FastifyReply { from( source?: string, opts?: fastifyReplyFrom.FastifyReplyFromHooks ): this; } } type FastifyReplyFrom = FastifyPluginCallback declare namespace fastifyReplyFrom { type QueryStringFunction = ( search: string | undefined, reqUrl: string, request: FastifyRequest ) => string export type RetryDetails = { err: Error; req: FastifyRequest; res: FastifyReply; attempt: number; retriesCount: number; getDefaultDelay: ( req: FastifyRequest, res: FastifyReply, err: Error, retries: number, ) => number | null; } export type RawServerResponse = RawReplyDefaultExpression & { stream: IncomingMessage } export interface FastifyReplyFromHooks { queryString?: { [key: string]: unknown } | QueryStringFunction; contentType?: string; retryDelay?: (details: RetryDetails) => number | null; retriesCount?: number; onResponse?: ( request: FastifyRequest, reply: FastifyReply, res: RawServerResponse ) => void; onError?: ( reply: FastifyReply, error: { error: Error } ) => void; body?: unknown; rewriteHeaders?: ( headers: Http2IncomingHttpHeaders | IncomingHttpHeaders, request?: FastifyRequest ) => Http2IncomingHttpHeaders | IncomingHttpHeaders; rewriteRequestHeaders?: ( request: FastifyRequest, headers: Http2IncomingHttpHeaders | IncomingHttpHeaders ) => Http2IncomingHttpHeaders | IncomingHttpHeaders; getUpstream?: ( request: FastifyRequest, base: string ) => string; method?: HTTPMethods; timeout?: number; } interface Http2Options { sessionTimeout?: number; requestTimeout?: number; sessionOptions?: ClientSessionOptions | SecureClientSessionOptions; requestOptions?: ClientSessionRequestOptions; } interface HttpOptions { agentOptions?: AgentOptions | SecureAgentOptions; requestOptions?: RequestOptions | SecureRequestOptions; agents?: { 'http:': Agent, 'https:': SecureAgent } } export interface FastifyReplyFromOptions { base?: string | string[]; cacheURLs?: number; disableCache?: boolean; http?: HttpOptions; http2?: Http2Options | boolean; undici?: Pool.Options & { proxy?: string | URL | ProxyAgent.Options } | { request: Dispatcher['request'] }; balancedPoolOptions?: Pool.Options & Record; contentTypesToEncode?: string[]; retryMethods?: (HTTPMethods | 'TRACE')[]; maxRetriesOn503?: number; disableRequestLogging?: boolean; globalAgent?: boolean; destroyAgent?: boolean; } export const fastifyReplyFrom: FastifyReplyFrom export { fastifyReplyFrom as default } } declare function fastifyReplyFrom (...params: Parameters): ReturnType export = fastifyReplyFrom