import { type WhookRouteDefinition } from '../types/routes.js'; import { type WhookAPICallbackDefinition, type WhookAPIHeaderDefinition, type WhookAPIParameterDefinition, type WhookAPIRequestBodyDefinition, type WhookAPIResponseDefinition, type WhookAPISchemaDefinition, } from '../types/openapi.js'; import { type WhookCronDefinition } from './crons.js'; import { type WhookConsumerDefinition } from './consumers.js'; import { type WhookTransformerDefinition } from './transformers.js'; import { type WhookCommandDefinition } from './commands.js'; import { type WhookPluginName } from '../services/WHOOK_RESOLVED_PLUGINS.js'; import { type WhookHandlerWrapperDefinition } from './wrappers.js'; export interface WhookDeclarationsOptions { /** File patterns to ignore */ ignoredFilePatterns?: string[]; /** Pattern to match and pick the cron name in the file name */ fileNamePatterns: [string, ...string[]]; } export const DEFAULT_DECLARATIONS_OPTIONS: WhookDeclarationsOptions = { ignoredFilePatterns: ['^__', '\\.(?:map|snap|(test|d)\\.(?:js|mjs|ts|mts))$'], fileNamePatterns: ['([^.]+)\\.(?:js|mjs|ts|mts)$'], }; export interface WhookDeclarationsTypesMap { parameter: WhookAPIParameterDefinition; header: WhookAPIHeaderDefinition; response: WhookAPIResponseDefinition; requestBody: WhookAPIRequestBodyDefinition; callback: WhookAPICallbackDefinition; schema: WhookAPISchemaDefinition; cron: WhookCronDefinition; consumer: WhookConsumerDefinition; route: WhookRouteDefinition; transformer: WhookTransformerDefinition; command: WhookCommandDefinition; handler: undefined; wrapper: WhookHandlerWrapperDefinition; } export interface WhookDeclaration< T extends keyof WhookDeclarationsTypesMap = keyof WhookDeclarationsTypesMap, > { url: `file:///${string}`; name: string; pluginName: WhookPluginName; type: T; content: WhookDeclarationsTypesMap[T]; } export interface WhookDeclarations { parameters: Record>; headers: Record>; responses: Record>; requestBodies: Record>; callbacks: Record>; schemas: Record>; crons: Record>; consumers: Record>; routes: Record>; transformers: Record>; commands: Record>; handlers: Record>; wrappers: Record>; }