import { ServerConnection } from '@jupyterlab/services'; import { requestAPI } from './request'; export interface VersionEntry { id: string; timestamp: number; name: string; description: string; hash: string; size: number; } export interface CommitResponse { entry: VersionEntry | null; skipped: boolean; reason: string | null; message: string | null; } export async function commitSnapshot( serverSettings: ServerConnection.ISettings, path: string, content: unknown, name: string, description: string ): Promise { return requestAPI('notebook-version/commit', serverSettings, { method: 'POST', body: JSON.stringify({ path, content, name, description }), headers: { 'Content-Type': 'application/json' } }); } export async function listSnapshots( serverSettings: ServerConnection.ISettings, path: string ): Promise { const endpoint = `notebook-version/list?path=${encodeURIComponent(path)}`; const response = await requestAPI<{ versions: VersionEntry[] }>( endpoint, serverSettings ); return response.versions; } export async function getSnapshotContent( serverSettings: ServerConnection.ISettings, path: string, id: string ): Promise { const endpoint = `notebook-version/content?path=${encodeURIComponent(path)}&id=${encodeURIComponent(id)}`; return requestAPI(endpoint, serverSettings); }