UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

101 lines • 2.98 kB
#!/usr/bin/env node /** * Test the ViewOnlySQLBuilder to ensure it's working correctly */ import { ViewOnlySQLBuilder } from '../intelligent-query-engine/ViewOnlySQLBuilder.js'; console.log('Testing ViewOnlySQLBuilder\n'); console.log('='.repeat(60)); const builder = new ViewOnlySQLBuilder(); // Test cases const testQueries = [ { name: 'Simple flag count', query: { find: 'flags', aggregations: [{ function: 'COUNT', field: '*', alias: 'flag_count' }] } }, { name: 'Flags by environment', query: { find: 'flags', select: ['flag_key', 'environment_key', 'enabled'], where: [ { field: 'project_id', operator: '=', value: '20224828075' } ] } }, { name: 'Temporal query - flags disabled for 30+ days', query: { find: 'flags', select: ['flag_key', 'environment_key'], where: [ { field: 'disabled_for_30_plus_days', operator: '=', value: 1 } ] } }, { name: 'Orphaned pages', query: { find: 'pages', select: ['entity_name', 'days_since_creation'], where: [ { field: 'entity_type', operator: '=', value: 'page' }, { field: 'usage_status', operator: '=', value: 'orphaned' } ], orderBy: [ { field: 'days_since_creation', direction: 'DESC' } ], limit: 5 } }, { name: 'Group by with aggregation', query: { find: 'flags', aggregations: [{ function: 'COUNT', field: '*', alias: 'count' }], groupBy: ['environment_key'], where: [ { field: 'enabled', operator: '=', value: 1 } ] } }, { name: 'Test invalid field (should fail)', query: { find: 'flags', select: ['flag_key', 'invalid_field_that_does_not_exist'], where: [ { field: 'project_id', operator: '=', value: '20224828075' } ] } } ]; // Run tests async function runTests() { for (const test of testQueries) { console.log(`\nšŸ“‹ Test: ${test.name}`); console.log('-'.repeat(40)); try { const sql = await builder.buildSQL(test.query); console.log('SQL Generated:'); console.log(sql); } catch (error) { console.log('Error:', error instanceof Error ? error.message : String(error)); } } console.log('\n' + '='.repeat(60)); console.log('ViewOnlySQLBuilder testing complete!'); } runTests().catch(console.error); //# sourceMappingURL=test-view-only-builder.js.map