@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
171 lines • 7.63 kB
JavaScript
/**
* Unified Field Mappings
*
* Centralizes all field name mappings from across the project
* to ensure consistency between different components.
*/
// Import the field name corrections directly
const FIELD_NAME_CORRECTIONS = {
activation_mode: 'activation_type',
event_type_name: 'event_type',
audience_targeting: 'audience_conditions',
targeting_conditions: 'audience_conditions',
page_targeting: 'page_ids',
metric_events: 'metrics',
traffic_split: 'traffic_allocation',
experiment_type: 'type',
flag_status: 'status',
match: 'match_type',
url_match: 'match_type',
matching_type: 'match_type',
conditional_activation: 'activation_type',
flag_key: 'key',
flag_name: 'name',
experiment_key: 'key',
audience_key: 'key',
page_key: 'key',
event_key: 'key',
campaign_key: 'key',
rule_key: 'key',
attribute_key: 'key'
};
/**
* Comprehensive field synonyms combining all existing mappings
* This is the single source of truth for field name variations
*/
export const UNIFIED_FIELD_SYNONYMS = {
// Core identifiers - from FieldMapper patterns + FIELD_NAME_CORRECTIONS
key: [
'key', 'id', 'identifier', 'unique key', 'unique id', 'slug', 'handle', 'ref', 'reference', 'token',
'lookup_key', 'natural_key', 'api key', 'external key', 'external id', 'shortcode',
'flag key', 'feature key', 'feature flag key', 'ff key', 'experiment key', 'test key',
'event key', 'event id', 'page key', 'variation key', 'variant key', 'rule key',
'metric key', 'audience key', 'campaign key', 'attribute key',
// From FIELD_NAME_CORRECTIONS
'flag_key', 'experiment_key', 'audience_key', 'page_key', 'event_key', 'campaign_key', 'rule_key', 'attribute_key'
],
name: [
'name', 'title', 'label', 'display name', 'display title', 'heading', 'caption',
'friendly_name', 'human_name', 'ui_name', 'title_text', 'experiment name', 'test name',
'ab test name', 'split test name', 'flag name', 'feature name', 'feature flag name',
'ff name', 'event name', 'metric name', 'audience name', 'segment name', 'page name',
'variation name', 'variant name', 'version name', 'campaign name', 'rule name',
'ruleset name', 'group name', 'nombre', 'flag_name'
],
description: [
'description', 'desc', 'descr', 'desciption', 'details', 'info', 'information',
'summary', 'about', 'purpose', 'notes', 'comments', 'blurb', 'overview', 'info_text',
'markdown', 'body', 'copy', 'synopsis', 'experiment description', 'test description',
'flag description', 'hypothesis', 'goal', 'objective', 'test hypothesis',
'the why', 'what is this for'
],
project_id: [
'project', 'project id', 'projectid', 'proj id', 'project identifier', 'project key',
'project ref', 'parent project', 'parent id', 'workspace', 'workspace id', 'app id',
'container id', 'namespace', 'namespace_id', 'project_id', 'projectId'
],
// Traffic and allocation
traffic_allocation: [
'traffic allocation', 'traffic_allocation', 'experiment allocation', 'total traffic',
'experiment traffic', 'test traffic', 'overall allocation', 'global allocation',
'audience size', 'sample size', 'coverage', 'total coverage', 'global percent',
'allocation total', 'traffic_split'
],
weight: [
'weight', 'traffic_weight', 'percentage', 'percent', 'allocation', 'traffic share',
'variation weight', 'split', 'variation_weight', 'variation percentage', 'traffic',
'percentage_included'
],
// Targeting
audience_conditions: [
'audience_conditions', 'audience_targeting', 'targeting_conditions', 'audiences',
'audience conditions', 'targeting', 'who', 'audience_ids', 'target_audience',
'audience targeting', 'segment targeting', 'user targeting', 'visitor targeting'
],
page_ids: [
'page_ids', 'pages', 'page_targeting', 'target_pages', 'page ids', 'page list',
'targeted pages', 'url targeting', 'page_targets'
],
// Metrics and events
metrics: [
'metrics', 'metric_events', 'goals', 'events', 'conversion events', 'tracking events',
'success metrics', 'kpis', 'measurements', 'conversions', 'metric list', 'objectives'
],
event_type: [
'event_type', 'type', 'event_type_name', 'eventType', 'category', 'event category',
'event_category', 'tracking type'
],
// Status fields
status: [
'status', 'state', 'phase', 'stage', 'lifecycle', 'run_state', 'campaign_status',
'test_state', 'current status', 'lifecycle status', 'workflow status', 'run status',
'experiment status', 'test status', 'flag_status'
],
enabled: [
'enabled', 'is enabled', 'enable', 'active', 'is active', 'activated', 'is activated',
'on', 'is on', 'turned on', 'is running', 'running', 'live', 'is live', 'published',
'is published', 'deployed', 'is deployed', 'status enabled', 'active status',
'activation status', 'toggle', 'switch', 'flag enabled', 'feature enabled',
'launched', 'rolled out', 'isrunning', 'toggle on', 'is_enabled', 'feature_enabled'
],
archived: [
'archived', 'is archived', 'deleted', 'is deleted', 'removed', 'is removed',
'inactive', 'is inactive', 'deprecated', 'is deprecated', 'disabled', 'is disabled',
'trashed', 'is trashed', 'soft deleted', 'marked for deletion', 'retired',
'withdrawn', 'hidden', 'is_archived'
],
// Variations
variations: [
'variations', 'variants', 'treatments', 'options', 'alternatives', 'versions',
'variation list', 'variant list', 'experiences', 'recipes', 'conditions'
],
// Feature flags specific
feature_enabled: [
'feature_enabled', 'feature enabled', 'flag enabled', 'enabled', 'active',
'is_enabled', 'feature_flag_enabled', 'ff_enabled'
],
variable_values: [
'variable_values', 'values', 'vars', 'variable_overrides', 'variable values',
'overrides', 'variable_settings', 'var_values'
],
variable_definitions: [
'variable_definitions', 'variables', 'vars', 'variable_defs', 'variable definitions',
'feature variables', 'flag variables', 'definitions'
],
// Activation
activation_type: [
'activation_type', 'activation_mode', 'activation type', 'trigger type',
'activation', 'trigger', 'conditional_activation'
],
// Matching
match_type: [
'match_type', 'match', 'url_match', 'matching_type', 'match type',
'matching', 'comparison', 'operator'
]
};
/**
* Get all synonyms for a field name
*/
export function getFieldSynonyms(fieldName) {
return UNIFIED_FIELD_SYNONYMS[fieldName] || [fieldName];
}
/**
* Find the canonical field name for a given synonym
*/
export function findCanonicalFieldName(synonym) {
const normalizedSynonym = synonym.toLowerCase().replace(/[_-]/g, ' ').trim();
for (const [canonical, synonyms] of Object.entries(UNIFIED_FIELD_SYNONYMS)) {
for (const syn of synonyms) {
const normalizedSyn = syn.toLowerCase().replace(/[_-]/g, ' ').trim();
if (normalizedSyn === normalizedSynonym) {
return canonical;
}
}
}
// Check FIELD_NAME_CORRECTIONS as fallback
if (FIELD_NAME_CORRECTIONS[synonym]) {
return FIELD_NAME_CORRECTIONS[synonym];
}
return null;
}
//# sourceMappingURL=UnifiedFieldMappings.js.map