/** * Functions in this module are provided for converting from Jupyter Notebook * Format v4 to nteract's in-memory format, affectionately referred to as * commutable. * * See: https://github.com/jupyter/nbformat/blob/62d6eb8803616d198eaa2024604d1fe923f2a7b3/nbformat/v4/nbformat.v4.schema.json * * The main goal here is consistency and compliance with the v4 spec. The types * contained in here (non Immutable ones) are constrained to the disk based * notebook format. * */ import { Record } from "immutable"; import { ImmutableCell } from "./cells"; import { ImmutableOutput, OnDiskOutput } from "./outputs"; import { ExecutionCount, JSONObject, MimeBundle, MultiLineString } from "./primitives"; import { ImmutableNotebook, NotebookRecordParams } from "./structures"; export interface CodeCell { cell_type: "code"; id?: string; metadata: JSONObject; execution_count: ExecutionCount; source: MultiLineString; outputs: OnDiskOutput[]; } export interface MarkdownCell { attachments?: { [filename: string]: MimeBundle; }; cell_type: "markdown"; id?: string; metadata: JSONObject; source: MultiLineString; } export interface RawCell { cell_type: "raw"; id?: string; metadata: JSONObject; source: MultiLineString; } export declare type Cell = CodeCell | MarkdownCell | RawCell; export interface NotebookV4 { cells: Cell[]; metadata: JSONObject; nbformat: 4; nbformat_minor: number; } export declare function fromJS(notebook: NotebookV4): Record & Readonly; export declare function outputToJS(output: ImmutableOutput): OnDiskOutput; /** * Converts an immutable cell to a JSON cell. * * @param immCell An immutable representation of a cell. * * @returns A JSON representation of the same cell. */ export declare function cellToJS(immCell: ImmutableCell): Cell; /** * Converts an immutable representation of a notebook to a JSON representation. * * @param immnb The immutable representation of a notebook. * * @returns The JSON representation of a notebook. */ export declare function toJS(immnb: ImmutableNotebook): NotebookV4; export declare function isNotebookV4(value: any): value is NotebookV4;