/** * Feature-First Auto-Orchestration API * * Convention over Configuration: * - method: Auto-inferred from folder name (get/post/put/delete/patch) * - path: Auto-inferred from folder structure (/features/api/v1/orders/post -> /api/v1/orders) * - steps: Automatically detects ./steps folder * - asyncTasks: Automatically detects ./async-tasks folder * * numflow.feature() - Separate complex business logic into multiple steps and auto-execute * * @example * ```javascript * // /features/api/v1/orders/post/index.js * const numflow = require('numflow') * * module.exports = numflow.feature({ * // method, path, steps, asyncTasks are all auto-inferred! * middlewares: [authenticate, authorize], * contextInitializer: (ctx, req, res) => { * ctx.userId = req.user?.id * ctx.orderData = req.body * }, * onError: async (error, ctx, req, res) => { * if (ctx.dbClient) { * await ctx.dbClient.query('ROLLBACK') * } * res.statusCode = 500 * res.end(JSON.stringify({ error: error.message })) * }, * }) * ``` */ import { FeatureConfig, FeatureHandler } from './types'; /** * Feature class * Creates HTTP request handler based on Feature configuration */ export declare class Feature { private config; private steps; private asyncTasks; private initialized; private basePath; constructor(config: FeatureConfig, basePath: string); /** * Update method and path from scanner's convention resolution * This is called by FeatureScanner when the feature's convention * was not properly resolved (e.g., when features base dir couldn't be found) */ updateConventions(method: string, apiPath: string, newBasePath?: string): void; /** * Initialize Feature * Discover and load Step and Async Task files */ initialize(): Promise; /** * Execute Feature-level middlewares * * Feature middleware support * Executes Feature-level middlewares sequentially * * @param req - Request object * @param res - Response object */ private runFeatureMiddlewares; /** * Create Feature handler * * @returns HTTP request handler */ getHandler(): FeatureHandler; /** * Get base path * Directory path of Feature configuration file */ private getBasePath; /** * Get Feature information */ getInfo(): { method: import("./types").HttpMethod | undefined; path: string | undefined; steps: number; asyncTasks: number; hasErrorHandler: boolean; }; } /** * numflow.feature() - Feature creation factory function * * @param config - Feature configuration * @returns Feature instance * * @example * ```javascript * // Convention over Configuration - auto-inference * // /features/api/v1/orders/post/index.js * const numflow = require('numflow') * * module.exports = numflow.feature({ * // method, path, steps, asyncTasks are all auto-inferred! * middlewares: [authenticate, authorize], * contextInitializer: (ctx, req, res) => { * ctx.userId = req.user?.id * ctx.orderData = req.body * }, * onError: async (error, ctx, req, res) => { * // Handle errors manually (transaction rollback, logging, etc.) * if (ctx.txId) { * await db.rollback(ctx.txId) * } * console.error('Order creation failed:', error) * res.statusCode = 500 * res.setHeader('Content-Type', 'application/json') * res.end(JSON.stringify({ error: error.message })) * }, * }) * * // Manual configuration is also possible (override Convention) * module.exports = numflow.feature({ * method: 'POST', * path: '/api/orders', * steps: './steps', * asyncTasks: './async-tasks', * // ... * }) * ``` */ export declare function feature(config?: FeatureConfig): Feature; export * from './types'; export { AutoDiscovery } from './auto-discovery'; export { AutoExecutor } from './auto-executor'; export { AutoErrorHandler } from './auto-error-handler'; export { AsyncTaskScheduler } from './async-task-scheduler'; export { ConventionResolver } from './convention'; export { FeatureScanner, scanFeatures, ScannedFeature, ScanOptions } from './feature-scanner'; export { retry, RETRY, isRetrySignal, RetrySignal } from './retry'; //# sourceMappingURL=feature.d.ts.map