UNPKG

@simonecoelhosfo/optimizely-mcp-server

Version:

Optimizely MCP Server for AI assistants with integrated CLI tools

224 lines 7.63 kB
/** * Entity Migration Constants * @description Constants and configuration values for the entity migration system */ /** * Entity dependency order for migration * Entities must be migrated in this order to satisfy foreign key constraints */ export const ENTITY_DEPENDENCY_ORDER = [ // Foundation entities (no dependencies) 'event', 'attribute', 'audience', // Secondary entities (depend on foundation) 'page', 'extension', 'group', // Platform-specific entities with dependencies 'flag', // Depends on audiences, attributes 'experiment', // Depends on audiences, events, pages (Web) 'campaign', // Depends on pages, audiences (Web) // Complex entities (depend on multiple other entities) 'webhook', // Can reference various entity types 'collaborator', // References projects and permissions 'environment' // Feature Experimentation environments ]; /** * Default migration options */ export const DEFAULT_MIGRATION_OPTIONS = { rollbackStrategy: 'partial', conflictResolution: 'ask', // Default to asking user for confirmation dryRun: false, validateOnly: false, continueOnError: true, maxRetries: 3, retryDelay: 1000, interactiveMode: true // Enable interactive confirmations by default }; /** * Entity-specific configuration */ export const ENTITY_CONFIG = { // Entities that support archiving instead of deletion ARCHIVABLE_ENTITIES: ['flag', 'experiment', 'campaign', 'audience'], // Entities that have platform-specific implementations PLATFORM_SPECIFIC_ENTITIES: ['flag', 'experiment', 'campaign', 'environment'], // Entities that require special handling for references REFERENCE_HEAVY_ENTITIES: ['flag', 'experiment', 'campaign'], // Maximum items per API request for each entity type MAX_PAGE_SIZE: { event: 100, attribute: 100, audience: 100, flag: 50, // Flags can be complex with many rules experiment: 50, campaign: 50, page: 100, extension: 100, group: 100, webhook: 100, collaborator: 100, environment: 100 } }; /** * Migration-specific error codes */ export const MIGRATION_ERROR_CODES = { // Configuration errors INVALID_CONFIG: 'MIGRATION_INVALID_CONFIG', MISSING_TOKEN: 'MIGRATION_MISSING_TOKEN', INVALID_PROJECT: 'MIGRATION_INVALID_PROJECT', // Operation errors FETCH_FAILED: 'MIGRATION_FETCH_FAILED', TRANSFORM_FAILED: 'MIGRATION_TRANSFORM_FAILED', CREATE_FAILED: 'MIGRATION_CREATE_FAILED', VALIDATE_FAILED: 'MIGRATION_VALIDATE_FAILED', // Dependency errors MISSING_DEPENDENCY: 'MIGRATION_MISSING_DEPENDENCY', CIRCULAR_DEPENDENCY: 'MIGRATION_CIRCULAR_DEPENDENCY', // Mapping errors MISSING_MAPPING: 'MIGRATION_MISSING_MAPPING', INVALID_MAPPING: 'MIGRATION_INVALID_MAPPING', // Platform errors PLATFORM_MISMATCH: 'MIGRATION_PLATFORM_MISMATCH', UNSUPPORTED_ENTITY: 'MIGRATION_UNSUPPORTED_ENTITY', // Progress errors CHECKPOINT_INVALID: 'MIGRATION_CHECKPOINT_INVALID', CHECKPOINT_EXPIRED: 'MIGRATION_CHECKPOINT_EXPIRED' }; /** * Progress reporting intervals */ export const PROGRESS_CONFIG = { // Update progress every N entities UPDATE_INTERVAL: 10, // Save checkpoint every N entities CHECKPOINT_INTERVAL: 50, // Estimated processing time per entity (ms) ESTIMATED_TIME_PER_ENTITY: { event: 200, attribute: 200, audience: 300, flag: 1000, // Flags are complex experiment: 800, campaign: 600, page: 200, extension: 300, group: 250, webhook: 300, collaborator: 200, environment: 400 } }; /** * File paths and naming conventions */ export const FILE_CONFIG = { // Default checkpoint directory CHECKPOINT_DIR: './data/migration-checkpoints', // Checkpoint file naming pattern CHECKPOINT_PATTERN: 'migration-{id}-checkpoint.json', // Report file naming pattern REPORT_PATTERN: 'migration-{id}-report-{timestamp}.json', // Default export directory for reports REPORT_DIR: './data/migration-reports' }; /** * Platform detection helpers */ export const PLATFORM_DETECTION = { // Fields that indicate Feature Experimentation FEATURE_FLAGS: ['is_flags_enabled', 'flags_enabled'], // Fields that indicate Web Experimentation WEB_FLAGS: ['is_web', 'web_snippet'], // Default platform if detection fails DEFAULT_PLATFORM: 'web' }; /** * Validation rules */ export const VALIDATION_RULES = { // Minimum length for various identifiers MIN_ID_LENGTH: 1, MAX_ID_LENGTH: 255, // Name constraints MIN_NAME_LENGTH: 1, MAX_NAME_LENGTH: 100, // Description constraints MAX_DESCRIPTION_LENGTH: 1000, // Array size limits MAX_ARRAY_SIZE: 1000, // Timeout for validation operations (ms) VALIDATION_TIMEOUT: 30000 }; /** * Reference field mappings * Maps entity types to their reference fields that need transformation */ export const REFERENCE_FIELDS = { flag: ['audience_ids', 'event_ids', 'attribute_ids'], experiment: ['audience_ids', 'event_ids', 'page_ids', 'campaign_id'], campaign: ['page_ids', 'audience_ids', 'experiment_ids'], ruleset: ['audience_id', 'flag_key'], rule: ['audience_id'], variation: ['flag_key', 'experiment_id'], webhook: ['project_id', 'event'] }; /** * Entity key fields * Defines which field is used as the unique identifier for each entity type in API operations * NOTE: For migration, see MIGRATION_SEARCH_FIELDS which uses semantic identifiers */ export const ENTITY_KEY_FIELDS = { event: 'key', attribute: 'key', audience: 'id', flag: 'key', experiment: 'id', campaign: 'id', page: 'id', extension: 'id', group: 'id', webhook: 'id', collaborator: 'id', environment: 'id' }; /** * Migration search fields * Defines which field to use for cross-project entity identification during migration * Uses user-defined semantic identifiers that have meaning across projects */ export const MIGRATION_SEARCH_FIELDS = { event: 'key', // User-defined, semantic meaning attribute: 'key', // User-defined, semantic meaning audience: 'name', // User-defined, semantic meaning flag: 'key', // User-defined, semantic meaning experiment: 'key', // User-defined when present, fallback to name campaign: 'name', // User-defined, semantic meaning page: 'name', // User-defined, semantic meaning extension: 'name', // User-defined, semantic meaning group: 'name', // User-defined, semantic meaning webhook: 'name', // User-defined, semantic meaning collaborator: 'id', // Special case - might need email lookup environment: 'key' // User-defined for FX environments }; /** * Progress messages */ export const PROGRESS_MESSAGES = { INITIALIZING: 'Initializing migration engine...', ANALYZING_DEPENDENCIES: 'Analyzing entity dependencies...', VALIDATING_CONFIG: 'Validating migration configuration...', FETCHING_ENTITIES: 'Fetching {type} entities from source project...', TRANSFORMING_REFERENCES: 'Transforming references for {type}...', CREATING_ENTITY: 'Creating {type}: {name}...', VALIDATING_ENTITY: 'Validating {type}: {name}...', CHECKPOINT_SAVED: 'Progress checkpoint saved', MIGRATION_COMPLETE: 'Migration completed successfully', ROLLING_BACK: 'Rolling back failed operations...', GENERATING_REPORT: 'Generating migration report...' }; //# sourceMappingURL=constants.js.map