Transforms legacy widget configurations into the standardized GlobalContextState format.
This migration handles the transition from various legacy configuration formats to the new
unified global context system. It detects which properties need updating and
preserves configurations that are already in the correct format.
What is migrated:
displayMode: Derived from widgetInstanceGlobalTimeContext/AutoRefreshContext flags
dateTimeContext: Normalized from dateFilter, date, dateFrom/dateTo, or interval fields
refreshOption: Converted from legacy 'interval'/'global-interval'/'none' values to LIVE/HISTORY
isAutoRefreshEnabled + refreshInterval: Determined from realtime flags and legacy settings
aggregation: Normalized from legacy 'NONE' string to null
Use case:
Call this on every widget configuration before rendering to ensure compatibility with
the global context system, regardless of when the widget was created or last saved.
Can be any object type, but should contain widget configuration fields.
legacy format or preserved if already valid. Returns input unchanged if null/undefined.
Example :// Legacy config with old format
const legacyConfig = {
widgetInstanceGlobalTimeContext: true,
dateFrom: '2024-01-01',
dateTo: '2024-01-02',
refreshOption: 'interval'
};
// After migration
const migrated = migrationService.migrateWidgetConfig(legacyConfig);
// {
// displayMode: 'dashboard',
// dateTimeContext: { dateFrom: '2024-01-01T00:00:00.000Z', dateTo: '2024-01-02T00:00:00.000Z', interval: 'custom' },
// refreshOption: 'live',
// isAutoRefreshEnabled: true,
// refreshInterval: 60000,
// aggregation: null
// }