(params: GenerateSnapshotFilenameParams)
| 96 | * @returns Filename in format '{slug}_{projectId}[_{notebookId}]_{timestamp}.snapshot.deepnote' |
| 97 | */ |
| 98 | export function generateSnapshotFilename(params: GenerateSnapshotFilenameParams): string { |
| 99 | const { slug, projectId, notebookId, timestamp = 'latest' } = params |
| 100 | const safeSlug = sanitizeFilenameComponent(slug) |
| 101 | const safeProjectId = sanitizeFilenameComponent(projectId) |
| 102 | // Normalize to the parser-readable, '_'-free canonical timestamp form so the name round-trips. A raw |
| 103 | // ISO string (':' '.' 'Z') otherwise sanitizes to '_'-laden text that incorrectly parses the notebook id or |
| 104 | // fails to match entirely. |
| 105 | const safeTimestamp = sanitizeTimestampComponent(timestamp) |
| 106 | if (notebookId) { |
| 107 | return `${safeSlug}_${safeProjectId}_${encodeNotebookIdForFilename(notebookId)}_${safeTimestamp}.snapshot.deepnote` |
| 108 | } |
| 109 | return `${safeSlug}_${safeProjectId}_${safeTimestamp}.snapshot.deepnote` |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Removes output-related fields from a block, returning a clean source block. |
no test coverage detected