UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

43 lines (42 loc) 1.4 kB
export const DEPRECATED_TOP_LEVEL_STATE_KEYS = { Schedule: { removedInVersion: 23, replacement: 'Use Scheduled Alerts for time-based triggers, or move Report schedules onto Export state.', }, }; const INTERNAL_STATE_METADATA_KEYS = new Set([ 'Uuid', 'AdaptableVersion', 'Source', 'Revision', ]); export function stripDeprecatedStateKeys(state, logger) { if (!state || typeof state !== 'object') { return state; } let cleanedState = state; let didStrip = false; for (const [key, info] of Object.entries(DEPRECATED_TOP_LEVEL_STATE_KEYS)) { const value = state[key]; if (value === undefined) { continue; } if (!didStrip) { cleanedState = { ...state }; didStrip = true; } delete cleanedState[key]; const hasContent = value !== null && typeof value === 'object' && Object.keys(value).some((k) => !INTERNAL_STATE_METADATA_KEYS.has(k)); const message = `Deprecated state key "${key}" was removed in AdapTable v${info.removedInVersion} and will be ignored.` + (hasContent && info.replacement ? ` ${info.replacement}` : ''); if (logger?.consoleInfo) { logger.consoleInfo(message); } else { console.info(message); } } return cleanedState; }