import { default as http, IncomingMessage } from 'node:http';
import { default as https } from 'node:https';
import { IncomingRequestProcessorResponse } from '../../requests/containers';
import { SigilResponse } from '../../responses';
import { Exception } from '../../responses/exceptions';
import { SigilOptions } from '../types/common.types';
import { $InternalPluginContext, $InternalRoutesListMethods, $SigilInternalPluginAPI } from '../types/internal.types';
/**
* Constructor type for Sigil plugins.
* @template P The SigilPlugin subclass.
*/
export type SigilPluginConstructor
= new () => P;
/**
* Base class for Sigil framework plugins.
* Provides lifecycle hooks and internal framework context.
*
* @template PluginConfig Configuration type for the plugin.
*/
export declare abstract class SigilPlugin = any> {
/**
* Static plugin name, usually the class name.
*/
static name: string;
/**
* Instance plugin name, copied from the constructor.
*/
readonly name: string;
/**
* Internal routes API for registering or inspecting routes.
*/
readonly $routes: $InternalRoutesListMethods;
/**
* Response template function from the framework.
*/
protected readonly $responseTemplate: SigilOptions["responseTemplate"];
/**
* Configuration object passed to this plugin.
*/
protected readonly $pluginConfig: PluginConfig;
/**
* Logger scoped to this plugin.
*/
protected readonly logger: $InternalPluginContext["logger"];
/**
* Internal Sigil API for plugins (mount, addMiddleware, etc.).
*/
protected readonly sigil: $SigilInternalPluginAPI;
/**
* Constructs the plugin with context injected by attachPluginContext.
* @protected
*/
protected constructor();
/**
* This method is triggered before an incoming request is processed.
* Interrupts internal request processing if `false` returned
*
* @param {IncomingMessage} request incoming HTTP request object.
* @param {http.ServerResponse} response HTTP server response object associated with the request.
*/
onBeforeRequestReceived(request: IncomingMessage, response: http.ServerResponse): boolean | void;
/**
* Called when a new request is received. Cannot modify the request,
* only for side effects such as logging or telemetry.
* @param request parsed incoming request object.
*/
onRequestReceived(request: IncomingRequestProcessorResponse): void;
/**
* Called just before a response is sent.
* Can replace the actual response by returning custom SigilResponse.
* @param request original HTTP incoming message.
* @param response SigilResponse or Exception being sent.
*/
onBeforeResponseSent(request: IncomingRequestProcessorResponse | null, response: SigilResponse | Exception): void | SigilResponse | Promise;
/**
* Called when the internal HTTP/S server starts listening.
* @param server HTTP or HTTPS server instance, or undefined in serverless mode.
*/
onInternalServerStarted(server: http.Server | https.Server | undefined): void;
/**
* Called whenever the route registry is updated (e.g., mount or unmount).
*/
onUpdateCallback(): void;
/**
* Called once when the plugin is first initialized.
*/
onInitialize(): any;
/**
* Called before the program exits (SIGINT, etc.).
* Can perform async cleanup.
* @returns optional promise for async cleanup tasks.
*/
onBeforeExit(): Promise | void;
}