20 lines
572 B
TypeScript
20 lines
572 B
TypeScript
import { ASTRALVIEW_SCHEMA_VERSION, type Screen } from './schema';
|
|
|
|
/**
|
|
* Placeholder for future schema migrations.
|
|
* Keep it pure and versioned.
|
|
*/
|
|
export function migrateScreen(input: unknown): Screen {
|
|
const s = input as Partial<Screen>;
|
|
if (!s || typeof s !== 'object') {
|
|
throw new Error('Invalid screen: not an object');
|
|
}
|
|
const version = (s as Screen).version;
|
|
if (version === ASTRALVIEW_SCHEMA_VERSION) {
|
|
return s as Screen;
|
|
}
|
|
|
|
// Future: apply incremental migrations.
|
|
throw new Error(`Unsupported screen version: ${String(version)}`);
|
|
}
|