UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

108 lines 2.85 kB
/** * Date/Time Function Handler - Phase 4B Implementation * * Enables all time-based analytics queries with SQLite date functions. * Supports relative dates, date ranges, and time arithmetic. * * User Requirement: "experiments that were started in the last 30 days" * * Features: * - Relative date parsing (LAST_30_DAYS, THIS_MONTH, etc.) * - Date range filtering (BETWEEN dates) * - Year/month/day filtering * - SQLite native date functions for optimal performance */ import type { QueryCondition } from './types.js'; export interface DateFilter { field: string; operator: 'LAST_N_DAYS' | 'BETWEEN' | 'YEAR' | 'MONTH' | 'DAY' | '>' | '<' | '>=' | '<=' | '='; value: string | number | [string, string]; resolvedSQL?: string; } export interface DateParseResult { sqlExpression: string; isValid: boolean; parsedValue?: any; error?: string; } export declare class DateFunctionHandler { private readonly DATE_FUNCTIONS; private readonly TIME_PATTERNS; constructor(); /** * Parse date filter condition and convert to SQL */ parseDateFilter(condition: QueryCondition): DateParseResult; /** * Handle BETWEEN operator for date ranges */ private handleBetweenOperator; /** * Handle comparison operators (>, <, >=, <=, =) */ private handleComparisonOperator; /** * Handle special date operators (YEAR, MONTH, etc.) */ private handleSpecialOperators; /** * Validate a date string in YYYY-MM-DD format */ private isValidDate; /** * Convert value to SQL date expression */ private convertToSQLDate; /** * Handle YEAR filtering */ private handleYearFilter; /** * Handle MONTH filtering */ private handleMonthFilter; /** * Handle DAY filtering */ private handleDayFilter; /** * Handle LAST_N_DAYS operator */ private handleLastNDays; /** * Validate date value format */ validateDateValue(value: any): { isValid: boolean; error?: string; }; /** * Get available date functions */ getAvailableFunctions(): string[]; /** * Get SQL for relative date */ getRelativeDateSQL(relativeDate: string): string | null; /** * Check if a field appears to be a date field */ isDateField(fieldName: string): boolean; /** * Get example queries for documentation */ getExampleQueries(): Array<{ description: string; query: any; }>; /** * Get statistics about date function usage */ getStatistics(): { totalFunctions: number; relativeFunctions: number; periodFunctions: number; supportedPatterns: number; }; } //# sourceMappingURL=DateFunctionHandler.d.ts.map