UNPKG

bowling-analysis-system

Version:

A comprehensive system for analyzing bowling techniques using video processing and metrics calculation

403 lines (388 loc) 9.06 kB
/** * @fileoverview Command schema definitions for the CLI * @module config/schema */ /** * Available commands in the system * @enum {string} */ const COMMANDS = { ANALYZE: 'analyze', VALIDATE: 'validate', REPORT: 'report', COMPARE: 'compare', HELP: 'help', VERSION: 'version' }; /** * Command configurations * @type {Object} */ const commandConfigs = { [COMMANDS.ANALYZE]: { description: 'Analyze bowling motion from video or keypoint data', options: { input: { alias: 'i', description: 'Input file path (video or keypoint data)', type: 'string', required: true }, output: { alias: 'o', description: 'Output directory for analysis results', type: 'string', default: './output' }, format: { alias: 'f', description: 'Output format (json, csv, html)', type: 'string', default: 'json' }, bias: { alias: 'b', description: 'Apply bias correction to metrics', type: 'boolean', default: true } } }, [COMMANDS.VALIDATE]: { description: 'Validate input data format and quality', options: { input: { alias: 'i', description: 'Input file path to validate', type: 'string', required: true }, schema: { alias: 's', description: 'Schema to validate against', type: 'string', default: 'keypoint' } } }, [COMMANDS.REPORT]: { description: 'Generate reports from analysis results', options: { input: { alias: 'i', description: 'Input directory with analysis results', type: 'string', required: true }, output: { alias: 'o', description: 'Output directory for reports', type: 'string', default: './reports' }, format: { alias: 'f', description: 'Report format (html, pdf, md)', type: 'string', default: 'html' } } }, [COMMANDS.COMPARE]: { description: 'Compare multiple analysis results', options: { inputs: { alias: 'i', description: 'Input files to compare (comma-separated)', type: 'string', required: true }, output: { alias: 'o', description: 'Output file for comparison results', type: 'string', default: './comparison.html' }, metrics: { alias: 'm', description: 'Metrics to compare (comma-separated)', type: 'string' } } }, [COMMANDS.HELP]: { description: 'Show help information', options: { command: { description: 'Command to show help for', type: 'string' }, verbose: { alias: 'v', description: 'Show detailed help', type: 'boolean', default: false } } }, [COMMANDS.VERSION]: { description: 'Show version information', options: {} } }; /** * Get configuration for a specific command * @param {string} command - Command name * @returns {Object} Command configuration */ function getCommandConfig(command) { return commandConfigs[command] || null; } /** * List all available commands * @returns {string[]} Array of command names */ function listCommands() { return Object.keys(commandConfigs); } /** * Get usage information for a command * @param {string} command - Command name * @returns {string} Usage information */ function getCommandUsage(command) { const config = getCommandConfig(command); if (!config) return ''; let usage = `Usage: bowling-analysis ${command}`; // Add required options const requiredOptions = Object.entries(config.options || {}) .filter(([_, opt]) => opt.required) .map(([name, opt]) => `--${name}=<${name}>`); if (requiredOptions.length > 0) { usage += ` ${requiredOptions.join(' ')}`; } // Add optional indicator if (Object.keys(config.options || {}).length > requiredOptions.length) { usage += ' [options]'; } return usage; } /** * @module config/schema * @description Configuration schema definitions for the application */ /** * Command line arguments schema * @type {Object} */ const commandSchema = { type: 'object', properties: { input: { type: 'string', description: 'Input video file path' }, output: { type: 'string', description: 'Output directory for results' }, template: { type: 'string', description: 'Pipeline template to use', enum: ['METRICS_ONLY', 'FULL_ANALYSIS'] }, format: { type: 'string', description: 'Output format for results', enum: ['json', 'csv', 'html'] }, config: { type: 'string', description: 'Custom configuration file path' } }, required: ['input'] }; /** * Pipeline configuration schema * @type {Object} */ const pipelineSchema = { type: 'object', properties: { template: { type: 'string', description: 'Pipeline template name' }, stages: { type: 'array', description: 'Pipeline processing stages', items: { type: 'object', properties: { type: { type: 'string', description: 'Stage type' }, config: { type: 'object', description: 'Stage configuration' } }, required: ['type'] } }, processorOptions: { type: 'object', description: 'Options for processor types' }, outputFormat: { type: 'string', description: 'Output format for results', enum: ['json', 'csv', 'html'] }, monitoring: { type: 'object', description: 'Pipeline monitoring configuration', properties: { enablePerformanceTracking: { type: 'boolean', description: 'Enable performance tracking' }, detailedMetrics: { type: 'boolean', description: 'Enable detailed metrics collection' } } } } }; /** * Application configuration schema * @type {Object} */ const appConfigSchema = { type: 'object', properties: { paths: { type: 'object', properties: { data: { type: 'string', description: 'Data directory path' }, output: { type: 'string', description: 'Output directory path' }, temp: { type: 'string', description: 'Temporary directory path' }, logs: { type: 'string', description: 'Log directory path' }, reference: { type: 'string', description: 'Reference data directory path' }, config: { type: 'string', description: 'Configuration directory path' } } }, processing: { type: 'object', properties: { maxConcurrentPipelines: { type: 'integer', description: 'Maximum number of concurrent pipelines' }, defaultTemplate: { type: 'string', description: 'Default pipeline template' }, metricSources: { type: 'array', description: 'Metric sources to use', items: { type: 'string' } } } }, logging: { type: 'object', properties: { level: { type: 'string', description: 'Logging level', enum: ['error', 'warn', 'info', 'debug', 'verbose'] }, format: { type: 'string', description: 'Log format', enum: ['simple', 'detailed', 'json'] } } }, system: { type: 'object', properties: { memoryLimit: { type: 'string', description: 'Memory limit for the application' }, timeoutSeconds: { type: 'integer', description: 'Operation timeout in seconds' } } }, monitoring: { type: 'object', properties: { enabled: { type: 'boolean', description: 'Enable performance monitoring' }, metricsInterval: { type: 'integer', description: 'Metrics collection interval in ms' }, retentionPeriod: { type: 'integer', description: 'Metrics retention period in minutes' } } }, api: { type: 'object', properties: { port: { type: 'integer', description: 'API server port' }, host: { type: 'string', description: 'API server host' }, cors: { type: 'object', description: 'CORS configuration' } } } } }; module.exports = { COMMANDS, getCommandConfig, listCommands, getCommandUsage, commandSchema, pipelineSchema, appConfigSchema };