(data: unknown)
| 35 | } |
| 36 | |
| 37 | export function validateNotebookFile(data: unknown): data is NotebookFile { |
| 38 | if (typeof data !== "object" || data === null) return false; |
| 39 | const obj = data as Record<string, unknown>; |
| 40 | if (typeof obj.version !== "number") return false; |
| 41 | if (typeof obj.title !== "string") return false; |
| 42 | if (!Array.isArray(obj.cells)) return false; |
| 43 | return obj.cells.every( |
| 44 | (cell: unknown) => |
| 45 | typeof cell === "object" && |
| 46 | cell !== null && |
| 47 | typeof (cell as Record<string, unknown>).type === "string" && |
| 48 | ((cell as Record<string, unknown>).type === "sql" || |
| 49 | (cell as Record<string, unknown>).type === "markdown") && |
| 50 | typeof (cell as Record<string, unknown>).content === "string", |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | export function deserializeNotebook(json: string): { |
| 55 | title: string; |
no outgoing calls
no test coverage detected