LCOV - code coverage report
Current view: top level - dashql-app/src/storage/migration/session - v4_notebooks_to_sessions.ts Coverage Total Hit
Test: DashQL 915828b Lines: 95.0 % 20 19
Test Date: 2026-11-06 19:30:32

            Line data    Source code
       1              : import { renameFileIfPresent } from '../migration_folder.js';
       2              : import type { SessionMigrationStep } from '../session_migration.js';
       3              : 
       4              : /// The metadata fields that named the session a notebook
       5            1 : const RENAMED_FIELDS: Record<string, string> = {
       6            1 :     notebookId: 'sessionId',
       7            1 :     notebookPath: 'sessionPath',
       8            1 : };
       9              : 
      10              : /// Notebooks are called sessions, the files and the identity of the metadata follow
      11            1 : export const notebooksToSessions: SessionMigrationStep = {
      12            1 :     version: 4,
      13            1 :     description: 'Rename notebooks as sessions',
      14            1 :     async migrate(folder) {
      15            1 :         await renameFileIfPresent(folder, 'dashql-notebook.json', 'dashql-session.json');
      16            1 :         await renameFileIfPresent(folder, 'dashql-notebook-index.json', 'dashql-session-index.json');
      17            1 :         const text = await folder.readText('dashql-session.json');
      18            1 :         if (text == null) {
      19            0 :             return;
      20              :         }
      21            1 :         const data = JSON.parse(text) as Record<string, unknown>;
      22            1 :         if (!Object.keys(data).some(key => key in RENAMED_FIELDS)) {
      23            1 :             return;
      24              :         }
      25            1 :         const renamed = Object.fromEntries(Object.entries(data).map(([key, value]) => [RENAMED_FIELDS[key] ?? key, value]));
      26            1 :         await folder.writeText('dashql-session.json', JSON.stringify(renamed, null, 2));
      27            1 :     },
      28            1 : };
        

Generated by: LCOV version 2.0-1