@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
214 lines • 6.05 kB
TypeScript
/**
* Dynamic Analytics Query Engine - Type Definitions
*/
export type QueryAction = 'count' | 'group' | 'trend' | 'compare' | 'find' | 'analyze' | 'summarize' | 'show' | 'list';
export type EntityType = 'experiments' | 'flags' | 'audiences' | 'variations' | 'rules' | 'changes' | 'events' | 'attributes' | 'pages' | 'projects' | 'environments' | 'rulesets' | 'flag' | 'experiment' | 'audience' | 'variation' | 'rule' | 'event' | 'attribute' | 'page' | 'project' | 'environment' | 'ruleset' | 'campaign' | 'campaigns' | 'experiment_results';
export type AggregationType = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'distinct' | 'count_if' | 'percent';
export type TimeGranularity = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
export type OutputFormat = 'table' | 'summary' | 'detailed' | 'json' | 'csv';
export interface TimeRange {
start?: Date | string;
end?: Date | string;
relative?: {
value: number;
unit: 'days' | 'weeks' | 'months' | 'hours';
};
}
export interface QueryFilter {
field: string;
operator: 'eq' | 'ne' | 'gt' | 'lt' | 'gte' | 'lte' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'exists' | 'not_exists' | 'array_contains' | 'array_length' | 'json_contains';
value?: any;
jsonPath?: string;
}
export interface OrderBy {
field: string;
direction: 'asc' | 'desc';
nullsFirst?: boolean;
}
export interface QueryIntent {
action: QueryAction;
primaryEntity: EntityType;
relatedEntities?: EntityType[];
metrics?: string[];
groupBy?: string[];
orderBy?: OrderBy[];
filters?: QueryFilter[];
aggregations?: AggregationType[];
timeRange?: TimeRange;
limit?: number;
offset?: number;
}
export interface EnhancedQueryIntent extends QueryIntent {
jsonPaths?: string[];
jsonFilters?: JsonFilter[];
transforms?: Transform[];
requiresJsonProcessing?: boolean;
jsonataExpression?: string;
entityType?: string;
platform?: 'web' | 'feature' | 'auto';
queryType?: string;
intent?: string;
filters?: any;
}
export interface JsonFilter {
path: string;
operator: string;
value?: any;
type?: 'nested' | 'array' | 'object' | 'scalar';
}
export interface Transform {
type: 'aggregate' | 'pivot' | 'flatten' | 'extract' | 'compute' | 'filter';
config: Record<string, any>;
}
export interface CompiledQuery {
sql: string;
params: any[];
metadata?: {
tables: string[];
estimatedRows?: number;
complexity?: 'simple' | 'moderate' | 'complex';
};
}
export interface HybridQuery {
type: 'sql-only' | 'hybrid';
sql: string;
params: any[];
jsonataExpression?: string;
processingPipeline?: ProcessingStep[];
}
export interface ProcessingStep {
type: 'filter' | 'transform' | 'aggregate' | 'sort' | 'limit';
operation: string;
params?: any;
}
export interface AnalyticsOptions {
format?: OutputFormat;
limit?: number;
offset?: number;
timeRange?: TimeRange;
projectId?: string;
interactive?: boolean;
includeMetadata?: boolean;
debug?: boolean;
simplified?: boolean;
keysOnly?: boolean;
pagination?: {
page_size?: number;
cursor?: string;
};
noCache?: boolean;
cacheTTL?: number;
}
export interface AnalyticsResult {
data: any[];
metadata?: {
query: string;
executionTime: number;
rowCount: number;
hasMore?: boolean;
insights?: Insight[];
optimizations?: any[];
cacheHit?: boolean;
};
error?: {
code: string;
message: string;
details?: any;
};
}
export interface Insight {
type: 'pattern' | 'anomaly' | 'trend' | 'recommendation';
title: string;
description: string;
severity?: 'info' | 'warning' | 'critical';
data?: any;
}
export interface SchemaInfo {
table: string;
columns: string[];
jsonColumns?: string[];
joins?: Record<string, JoinInfo>;
aggregatable?: string[];
groupable?: string[];
countable?: Record<string, string>;
}
export interface JoinInfo {
table: string;
on: string;
type: 'LEFT' | 'INNER' | 'RIGHT' | 'FULL';
fromTable?: string;
toTable?: string;
joinType?: 'LEFT' | 'INNER' | 'RIGHT' | 'FULL';
joinCondition?: string;
}
export interface QueryTemplate {
id: string;
name: string;
description: string;
category: string;
parameters: TemplateParameter[];
baseQuery: string;
jsonataExpression?: string;
examples?: string[];
}
export interface TemplateParameter {
name: string;
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
required: boolean;
default?: any;
description?: string;
validation?: {
enum?: any[];
pattern?: string;
min?: number;
max?: number;
};
}
export interface InteractiveSession {
id: string;
state: 'initial' | 'clarifying' | 'processing' | 'complete';
context: Record<string, any>;
history: InteractionStep[];
}
export interface InteractionStep {
type: 'question' | 'answer' | 'result';
timestamp: Date;
content: any;
}
export type SchemaMap = Record<EntityType, SchemaInfo>;
export interface FieldInfo {
table: string;
column: string;
isJsonPath: boolean;
jsonPath?: string;
dataType: string;
}
export interface FieldMappingResult {
success: boolean;
table?: string;
column?: string;
isJsonPath?: boolean;
jsonPath?: string;
error?: string;
suggestion?: string;
confidence: MappingConfidence;
}
export declare enum MappingConfidence {
NONE = 0,
LOW = 1,
MEDIUM = 2,
HIGH = 3
}
export interface FieldMapping {
sqlField: string;
requiredJoin?: string;
additionalConditions?: string[];
requiresJsonProcessing?: boolean;
jsonataPath?: string;
}
export interface JoinRequirement {
table: string;
condition: string;
type?: 'LEFT' | 'INNER' | 'RIGHT' | 'FULL';
}
//# sourceMappingURL=types.d.ts.map