@deepnote/convert 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +2 -2
- package/dist/{src-zxlAKpnq.js → src-CWHTtGro.js} +23 -3
- package/dist/{src-1XGCb_OZ.cjs → src-DHLflV_K.cjs} +28 -2
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { N as convertDeepnoteFileToJupyterFiles, O as convertDeepnoteFileToMarimoFiles, _ as isMarimoContent, a as convertPercentFilesToDeepnoteFile, b as convertDeepnoteFileToQuartoFiles, d as convertMarimoFilesToDeepnoteFile, p as convertIpynbFilesToDeepnoteFile, r as convertQuartoFilesToDeepnoteFile, v as isPercentContent, w as convertDeepnoteFileToPercentFiles } from "./src-CWHTtGro.js";
|
|
3
3
|
import { cli } from "cleye";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { basename, extname, resolve } from "node:path";
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const require_src = require('./src-
|
|
1
|
+
const require_src = require('./src-DHLflV_K.cjs');
|
|
2
2
|
|
|
3
|
+
exports.convertBlockToJupyterCell = require_src.convertBlockToJupyterCell;
|
|
3
4
|
exports.convertBlocksToJupyterNotebook = require_src.convertBlocksToJupyterNotebook;
|
|
4
5
|
exports.convertBlocksToMarimoApp = require_src.convertBlocksToMarimoApp;
|
|
5
6
|
exports.convertBlocksToPercentNotebook = require_src.convertBlocksToPercentNotebook;
|
package/dist/index.d.cts
CHANGED
|
@@ -110,6 +110,27 @@ declare function convertDeepnoteToJupyterNotebooks(deepnoteFile: DeepnoteFile):
|
|
|
110
110
|
* Each notebook in the Deepnote project becomes a separate .ipynb file.
|
|
111
111
|
*/
|
|
112
112
|
declare function convertDeepnoteFileToJupyterFiles(deepnoteFilePath: string, options: ConvertDeepnoteFileToJupyterOptions): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Converts a single Deepnote block to a Jupyter cell.
|
|
115
|
+
* This is useful for streaming export scenarios where blocks need to be
|
|
116
|
+
* processed one at a time rather than converting an entire notebook at once.
|
|
117
|
+
*
|
|
118
|
+
* @param block - A single DeepnoteBlock to convert
|
|
119
|
+
* @returns A JupyterCell object
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* import { convertBlockToJupyterCell } from '@deepnote/convert'
|
|
124
|
+
* import type { JupyterCell } from '@deepnote/convert'
|
|
125
|
+
*
|
|
126
|
+
* // Streaming export example
|
|
127
|
+
* for await (const block of blockStream) {
|
|
128
|
+
* const cell: JupyterCell = convertBlockToJupyterCell(block)
|
|
129
|
+
* outputStream.write(JSON.stringify(cell))
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
declare function convertBlockToJupyterCell(block: DeepnoteBlock): JupyterCell;
|
|
113
134
|
//#endregion
|
|
114
135
|
//#region src/types/marimo.d.ts
|
|
115
136
|
/**
|
|
@@ -630,4 +651,4 @@ declare function convertQuartoDocumentsToDeepnote(documents: QuartoDocumentInput
|
|
|
630
651
|
*/
|
|
631
652
|
declare function convertQuartoFilesToDeepnoteFile(inputFilePaths: string[], options: ConvertQuartoFilesToDeepnoteFileOptions): Promise<void>;
|
|
632
653
|
//#endregion
|
|
633
|
-
export { type ConvertBlocksToJupyterOptions, type ConvertDeepnoteFileToMarimoOptions, type ConvertDeepnoteFileToPercentOptions, type ConvertDeepnoteFileToQuartoOptions, type ConvertIpynbFilesToDeepnoteFileOptions, type ConvertJupyterNotebookOptions, type ConvertMarimoAppOptions, type ConvertMarimoAppsToDeepnoteOptions, type ConvertMarimoFilesToDeepnoteFileOptions, type ConvertPercentFilesToDeepnoteFileOptions, type ConvertPercentNotebookOptions, type ConvertQuartoDocumentOptions, type ConvertQuartoFilesToDeepnoteFileOptions, type JupyterCell, type JupyterNotebook, type JupyterNotebookInput, type MarimoApp, type MarimoAppInput, type MarimoCell, type NotebookFormat, type PercentCell, type PercentNotebook, type PercentNotebookInput, type QuartoCell, type QuartoCellOptions, type QuartoDocument, type QuartoDocumentInput, type QuartoFrontmatter, convertBlocksToJupyterNotebook, convertBlocksToMarimoApp, convertBlocksToPercentNotebook, convertBlocksToQuartoDocument, convertDeepnoteFileToJupyterFiles as convertDeepnoteFileToJupyter, convertDeepnoteFileToMarimoFiles, convertDeepnoteFileToPercentFiles, convertDeepnoteFileToQuartoFiles, convertDeepnoteToJupyterNotebooks, convertDeepnoteToMarimoApps, convertDeepnoteToPercentNotebooks, convertDeepnoteToQuartoDocuments, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote, convertMarimoAppToBlocks, convertMarimoAppsToDeepnote, convertMarimoFilesToDeepnoteFile, convertPercentFilesToDeepnoteFile, convertPercentNotebookToBlocks, convertPercentNotebooksToDeepnote, convertQuartoDocumentToBlocks, convertQuartoDocumentsToDeepnote, convertQuartoFilesToDeepnoteFile, detectFormat, parseMarimoFormat, parsePercentFormat, parseQuartoFormat, serializeMarimoFormat, serializePercentFormat, serializeQuartoFormat };
|
|
654
|
+
export { type ConvertBlocksToJupyterOptions, type ConvertDeepnoteFileToMarimoOptions, type ConvertDeepnoteFileToPercentOptions, type ConvertDeepnoteFileToQuartoOptions, type ConvertIpynbFilesToDeepnoteFileOptions, type ConvertJupyterNotebookOptions, type ConvertMarimoAppOptions, type ConvertMarimoAppsToDeepnoteOptions, type ConvertMarimoFilesToDeepnoteFileOptions, type ConvertPercentFilesToDeepnoteFileOptions, type ConvertPercentNotebookOptions, type ConvertQuartoDocumentOptions, type ConvertQuartoFilesToDeepnoteFileOptions, type JupyterCell, type JupyterNotebook, type JupyterNotebookInput, type MarimoApp, type MarimoAppInput, type MarimoCell, type NotebookFormat, type PercentCell, type PercentNotebook, type PercentNotebookInput, type QuartoCell, type QuartoCellOptions, type QuartoDocument, type QuartoDocumentInput, type QuartoFrontmatter, convertBlockToJupyterCell, convertBlocksToJupyterNotebook, convertBlocksToMarimoApp, convertBlocksToPercentNotebook, convertBlocksToQuartoDocument, convertDeepnoteFileToJupyterFiles as convertDeepnoteFileToJupyter, convertDeepnoteFileToMarimoFiles, convertDeepnoteFileToPercentFiles, convertDeepnoteFileToQuartoFiles, convertDeepnoteToJupyterNotebooks, convertDeepnoteToMarimoApps, convertDeepnoteToPercentNotebooks, convertDeepnoteToQuartoDocuments, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote, convertMarimoAppToBlocks, convertMarimoAppsToDeepnote, convertMarimoFilesToDeepnoteFile, convertPercentFilesToDeepnoteFile, convertPercentNotebookToBlocks, convertPercentNotebooksToDeepnote, convertQuartoDocumentToBlocks, convertQuartoDocumentsToDeepnote, convertQuartoFilesToDeepnoteFile, detectFormat, parseMarimoFormat, parsePercentFormat, parseQuartoFormat, serializeMarimoFormat, serializePercentFormat, serializeQuartoFormat };
|
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,27 @@ declare function convertDeepnoteToJupyterNotebooks(deepnoteFile: DeepnoteFile):
|
|
|
110
110
|
* Each notebook in the Deepnote project becomes a separate .ipynb file.
|
|
111
111
|
*/
|
|
112
112
|
declare function convertDeepnoteFileToJupyterFiles(deepnoteFilePath: string, options: ConvertDeepnoteFileToJupyterOptions): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Converts a single Deepnote block to a Jupyter cell.
|
|
115
|
+
* This is useful for streaming export scenarios where blocks need to be
|
|
116
|
+
* processed one at a time rather than converting an entire notebook at once.
|
|
117
|
+
*
|
|
118
|
+
* @param block - A single DeepnoteBlock to convert
|
|
119
|
+
* @returns A JupyterCell object
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* import { convertBlockToJupyterCell } from '@deepnote/convert'
|
|
124
|
+
* import type { JupyterCell } from '@deepnote/convert'
|
|
125
|
+
*
|
|
126
|
+
* // Streaming export example
|
|
127
|
+
* for await (const block of blockStream) {
|
|
128
|
+
* const cell: JupyterCell = convertBlockToJupyterCell(block)
|
|
129
|
+
* outputStream.write(JSON.stringify(cell))
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
declare function convertBlockToJupyterCell(block: DeepnoteBlock): JupyterCell;
|
|
113
134
|
//#endregion
|
|
114
135
|
//#region src/types/marimo.d.ts
|
|
115
136
|
/**
|
|
@@ -630,4 +651,4 @@ declare function convertQuartoDocumentsToDeepnote(documents: QuartoDocumentInput
|
|
|
630
651
|
*/
|
|
631
652
|
declare function convertQuartoFilesToDeepnoteFile(inputFilePaths: string[], options: ConvertQuartoFilesToDeepnoteFileOptions): Promise<void>;
|
|
632
653
|
//#endregion
|
|
633
|
-
export { type ConvertBlocksToJupyterOptions, type ConvertDeepnoteFileToMarimoOptions, type ConvertDeepnoteFileToPercentOptions, type ConvertDeepnoteFileToQuartoOptions, type ConvertIpynbFilesToDeepnoteFileOptions, type ConvertJupyterNotebookOptions, type ConvertMarimoAppOptions, type ConvertMarimoAppsToDeepnoteOptions, type ConvertMarimoFilesToDeepnoteFileOptions, type ConvertPercentFilesToDeepnoteFileOptions, type ConvertPercentNotebookOptions, type ConvertQuartoDocumentOptions, type ConvertQuartoFilesToDeepnoteFileOptions, type JupyterCell, type JupyterNotebook, type JupyterNotebookInput, type MarimoApp, type MarimoAppInput, type MarimoCell, type NotebookFormat, type PercentCell, type PercentNotebook, type PercentNotebookInput, type QuartoCell, type QuartoCellOptions, type QuartoDocument, type QuartoDocumentInput, type QuartoFrontmatter, convertBlocksToJupyterNotebook, convertBlocksToMarimoApp, convertBlocksToPercentNotebook, convertBlocksToQuartoDocument, convertDeepnoteFileToJupyterFiles as convertDeepnoteFileToJupyter, convertDeepnoteFileToMarimoFiles, convertDeepnoteFileToPercentFiles, convertDeepnoteFileToQuartoFiles, convertDeepnoteToJupyterNotebooks, convertDeepnoteToMarimoApps, convertDeepnoteToPercentNotebooks, convertDeepnoteToQuartoDocuments, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote, convertMarimoAppToBlocks, convertMarimoAppsToDeepnote, convertMarimoFilesToDeepnoteFile, convertPercentFilesToDeepnoteFile, convertPercentNotebookToBlocks, convertPercentNotebooksToDeepnote, convertQuartoDocumentToBlocks, convertQuartoDocumentsToDeepnote, convertQuartoFilesToDeepnoteFile, detectFormat, parseMarimoFormat, parsePercentFormat, parseQuartoFormat, serializeMarimoFormat, serializePercentFormat, serializeQuartoFormat };
|
|
654
|
+
export { type ConvertBlocksToJupyterOptions, type ConvertDeepnoteFileToMarimoOptions, type ConvertDeepnoteFileToPercentOptions, type ConvertDeepnoteFileToQuartoOptions, type ConvertIpynbFilesToDeepnoteFileOptions, type ConvertJupyterNotebookOptions, type ConvertMarimoAppOptions, type ConvertMarimoAppsToDeepnoteOptions, type ConvertMarimoFilesToDeepnoteFileOptions, type ConvertPercentFilesToDeepnoteFileOptions, type ConvertPercentNotebookOptions, type ConvertQuartoDocumentOptions, type ConvertQuartoFilesToDeepnoteFileOptions, type JupyterCell, type JupyterNotebook, type JupyterNotebookInput, type MarimoApp, type MarimoAppInput, type MarimoCell, type NotebookFormat, type PercentCell, type PercentNotebook, type PercentNotebookInput, type QuartoCell, type QuartoCellOptions, type QuartoDocument, type QuartoDocumentInput, type QuartoFrontmatter, convertBlockToJupyterCell, convertBlocksToJupyterNotebook, convertBlocksToMarimoApp, convertBlocksToPercentNotebook, convertBlocksToQuartoDocument, convertDeepnoteFileToJupyterFiles as convertDeepnoteFileToJupyter, convertDeepnoteFileToMarimoFiles, convertDeepnoteFileToPercentFiles, convertDeepnoteFileToQuartoFiles, convertDeepnoteToJupyterNotebooks, convertDeepnoteToMarimoApps, convertDeepnoteToPercentNotebooks, convertDeepnoteToQuartoDocuments, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote, convertMarimoAppToBlocks, convertMarimoAppsToDeepnote, convertMarimoFilesToDeepnoteFile, convertPercentFilesToDeepnoteFile, convertPercentNotebookToBlocks, convertPercentNotebooksToDeepnote, convertQuartoDocumentToBlocks, convertQuartoDocumentsToDeepnote, convertQuartoFilesToDeepnoteFile, detectFormat, parseMarimoFormat, parsePercentFormat, parseQuartoFormat, serializeMarimoFormat, serializePercentFormat, serializeQuartoFormat };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as serializeMarimoFormat, C as convertBlocksToPercentNotebook, D as convertBlocksToMarimoApp, E as serializePercentFormat, M as
|
|
1
|
+
import { A as serializeMarimoFormat, C as convertBlocksToPercentNotebook, D as convertBlocksToMarimoApp, E as serializePercentFormat, M as convertBlocksToJupyterNotebook, N as convertDeepnoteFileToJupyterFiles, O as convertDeepnoteFileToMarimoFiles, P as convertDeepnoteToJupyterNotebooks, S as serializeQuartoFormat, T as convertDeepnoteToPercentNotebooks, a as convertPercentFilesToDeepnoteFile, b as convertDeepnoteFileToQuartoFiles, c as parsePercentFormat, d as convertMarimoFilesToDeepnoteFile, f as parseMarimoFormat, g as detectFormat, h as convertJupyterNotebooksToDeepnote, i as parseQuartoFormat, j as convertBlockToJupyterCell, k as convertDeepnoteToMarimoApps, l as convertMarimoAppToBlocks, m as convertJupyterNotebookToBlocks, n as convertQuartoDocumentsToDeepnote, o as convertPercentNotebookToBlocks, p as convertIpynbFilesToDeepnoteFile, r as convertQuartoFilesToDeepnoteFile, s as convertPercentNotebooksToDeepnote, t as convertQuartoDocumentToBlocks, u as convertMarimoAppsToDeepnote, w as convertDeepnoteFileToPercentFiles, x as convertDeepnoteToQuartoDocuments, y as convertBlocksToQuartoDocument } from "./src-CWHTtGro.js";
|
|
2
2
|
|
|
3
|
-
export { convertBlocksToJupyterNotebook, convertBlocksToMarimoApp, convertBlocksToPercentNotebook, convertBlocksToQuartoDocument, convertDeepnoteFileToJupyterFiles as convertDeepnoteFileToJupyter, convertDeepnoteFileToMarimoFiles, convertDeepnoteFileToPercentFiles, convertDeepnoteFileToQuartoFiles, convertDeepnoteToJupyterNotebooks, convertDeepnoteToMarimoApps, convertDeepnoteToPercentNotebooks, convertDeepnoteToQuartoDocuments, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote, convertMarimoAppToBlocks, convertMarimoAppsToDeepnote, convertMarimoFilesToDeepnoteFile, convertPercentFilesToDeepnoteFile, convertPercentNotebookToBlocks, convertPercentNotebooksToDeepnote, convertQuartoDocumentToBlocks, convertQuartoDocumentsToDeepnote, convertQuartoFilesToDeepnoteFile, detectFormat, parseMarimoFormat, parsePercentFormat, parseQuartoFormat, serializeMarimoFormat, serializePercentFormat, serializeQuartoFormat };
|
|
3
|
+
export { convertBlockToJupyterCell, convertBlocksToJupyterNotebook, convertBlocksToMarimoApp, convertBlocksToPercentNotebook, convertBlocksToQuartoDocument, convertDeepnoteFileToJupyterFiles as convertDeepnoteFileToJupyter, convertDeepnoteFileToMarimoFiles, convertDeepnoteFileToPercentFiles, convertDeepnoteFileToQuartoFiles, convertDeepnoteToJupyterNotebooks, convertDeepnoteToMarimoApps, convertDeepnoteToPercentNotebooks, convertDeepnoteToQuartoDocuments, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote, convertMarimoAppToBlocks, convertMarimoAppsToDeepnote, convertMarimoFilesToDeepnoteFile, convertPercentFilesToDeepnoteFile, convertPercentNotebookToBlocks, convertPercentNotebooksToDeepnote, convertQuartoDocumentToBlocks, convertQuartoDocumentsToDeepnote, convertQuartoFilesToDeepnoteFile, detectFormat, parseMarimoFormat, parsePercentFormat, parseQuartoFormat, serializeMarimoFormat, serializePercentFormat, serializeQuartoFormat };
|
|
@@ -98,7 +98,7 @@ function sortKeysAlphabetically(obj) {
|
|
|
98
98
|
*/
|
|
99
99
|
function convertBlocksToJupyterNotebook(blocks, options) {
|
|
100
100
|
return {
|
|
101
|
-
cells: blocks.map((block) =>
|
|
101
|
+
cells: blocks.map((block) => convertBlockToJupyterCell(block)),
|
|
102
102
|
metadata: {
|
|
103
103
|
deepnote_notebook_id: options.notebookId,
|
|
104
104
|
deepnote_notebook_name: options.notebookName,
|
|
@@ -155,7 +155,27 @@ async function convertDeepnoteFileToJupyterFiles(deepnoteFilePath, options) {
|
|
|
155
155
|
await fs.writeFile(filePath, JSON.stringify(notebook, null, 2), "utf-8");
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Converts a single Deepnote block to a Jupyter cell.
|
|
160
|
+
* This is useful for streaming export scenarios where blocks need to be
|
|
161
|
+
* processed one at a time rather than converting an entire notebook at once.
|
|
162
|
+
*
|
|
163
|
+
* @param block - A single DeepnoteBlock to convert
|
|
164
|
+
* @returns A JupyterCell object
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* import { convertBlockToJupyterCell } from '@deepnote/convert'
|
|
169
|
+
* import type { JupyterCell } from '@deepnote/convert'
|
|
170
|
+
*
|
|
171
|
+
* // Streaming export example
|
|
172
|
+
* for await (const block of blockStream) {
|
|
173
|
+
* const cell: JupyterCell = convertBlockToJupyterCell(block)
|
|
174
|
+
* outputStream.write(JSON.stringify(cell))
|
|
175
|
+
* }
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
function convertBlockToJupyterCell(block) {
|
|
159
179
|
const content = block.content || "";
|
|
160
180
|
const jupyterCellType = convertBlockTypeToJupyter(block.type);
|
|
161
181
|
const executionStartedAt = "executionStartedAt" in block ? block.executionStartedAt : void 0;
|
|
@@ -1482,4 +1502,4 @@ function convertCellToBlock(cell, index, idGenerator) {
|
|
|
1482
1502
|
}
|
|
1483
1503
|
|
|
1484
1504
|
//#endregion
|
|
1485
|
-
export { serializeMarimoFormat as A, convertBlocksToPercentNotebook as C, convertBlocksToMarimoApp as D, serializePercentFormat as E,
|
|
1505
|
+
export { serializeMarimoFormat as A, convertBlocksToPercentNotebook as C, convertBlocksToMarimoApp as D, serializePercentFormat as E, convertBlocksToJupyterNotebook as M, convertDeepnoteFileToJupyterFiles as N, convertDeepnoteFileToMarimoFiles as O, convertDeepnoteToJupyterNotebooks as P, serializeQuartoFormat as S, convertDeepnoteToPercentNotebooks as T, isMarimoContent as _, convertPercentFilesToDeepnoteFile as a, convertDeepnoteFileToQuartoFiles as b, parsePercentFormat as c, convertMarimoFilesToDeepnoteFile as d, parseMarimoFormat as f, detectFormat as g, convertJupyterNotebooksToDeepnote as h, parseQuartoFormat as i, convertBlockToJupyterCell as j, convertDeepnoteToMarimoApps as k, convertMarimoAppToBlocks as l, convertJupyterNotebookToBlocks as m, convertQuartoDocumentsToDeepnote as n, convertPercentNotebookToBlocks as o, convertIpynbFilesToDeepnoteFile as p, convertQuartoFilesToDeepnoteFile as r, convertPercentNotebooksToDeepnote as s, convertQuartoDocumentToBlocks as t, convertMarimoAppsToDeepnote as u, isPercentContent as v, convertDeepnoteFileToPercentFiles as w, convertDeepnoteToQuartoDocuments as x, convertBlocksToQuartoDocument as y };
|
|
@@ -126,7 +126,7 @@ function sortKeysAlphabetically(obj) {
|
|
|
126
126
|
*/
|
|
127
127
|
function convertBlocksToJupyterNotebook(blocks, options) {
|
|
128
128
|
return {
|
|
129
|
-
cells: blocks.map((block) =>
|
|
129
|
+
cells: blocks.map((block) => convertBlockToJupyterCell(block)),
|
|
130
130
|
metadata: {
|
|
131
131
|
deepnote_notebook_id: options.notebookId,
|
|
132
132
|
deepnote_notebook_name: options.notebookName,
|
|
@@ -183,7 +183,27 @@ async function convertDeepnoteFileToJupyterFiles(deepnoteFilePath, options) {
|
|
|
183
183
|
await node_fs_promises.default.writeFile(filePath, JSON.stringify(notebook, null, 2), "utf-8");
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Converts a single Deepnote block to a Jupyter cell.
|
|
188
|
+
* This is useful for streaming export scenarios where blocks need to be
|
|
189
|
+
* processed one at a time rather than converting an entire notebook at once.
|
|
190
|
+
*
|
|
191
|
+
* @param block - A single DeepnoteBlock to convert
|
|
192
|
+
* @returns A JupyterCell object
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* import { convertBlockToJupyterCell } from '@deepnote/convert'
|
|
197
|
+
* import type { JupyterCell } from '@deepnote/convert'
|
|
198
|
+
*
|
|
199
|
+
* // Streaming export example
|
|
200
|
+
* for await (const block of blockStream) {
|
|
201
|
+
* const cell: JupyterCell = convertBlockToJupyterCell(block)
|
|
202
|
+
* outputStream.write(JSON.stringify(cell))
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
function convertBlockToJupyterCell(block) {
|
|
187
207
|
const content = block.content || "";
|
|
188
208
|
const jupyterCellType = convertBlockTypeToJupyter(block.type);
|
|
189
209
|
const executionStartedAt = "executionStartedAt" in block ? block.executionStartedAt : void 0;
|
|
@@ -1516,6 +1536,12 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
1516
1536
|
return __toESM;
|
|
1517
1537
|
}
|
|
1518
1538
|
});
|
|
1539
|
+
Object.defineProperty(exports, 'convertBlockToJupyterCell', {
|
|
1540
|
+
enumerable: true,
|
|
1541
|
+
get: function () {
|
|
1542
|
+
return convertBlockToJupyterCell;
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1519
1545
|
Object.defineProperty(exports, 'convertBlocksToJupyterNotebook', {
|
|
1520
1546
|
enumerable: true,
|
|
1521
1547
|
get: function () {
|