@deepnote/convert 2.1.2 → 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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_src = require('./src-DI6mrd_2.cjs');
2
+ const require_src = require('./src-DHLflV_K.cjs');
3
3
  let cleye = require("cleye");
4
4
  cleye = require_src.__toESM(cleye);
5
5
  let node_fs_promises = require("node:fs/promises");
package/dist/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { M 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-oALQkXiP.js";
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-DI6mrd_2.cjs');
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
  /**
@@ -409,7 +430,7 @@ interface ConvertIpynbFilesToDeepnoteFileOptions {
409
430
  projectName: string;
410
431
  }
411
432
  interface ConvertJupyterNotebookOptions {
412
- /** Custom ID generator function. Defaults to uuid v4. */
433
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
413
434
  idGenerator?: () => string;
414
435
  }
415
436
  interface JupyterNotebookInput {
@@ -457,7 +478,7 @@ interface ConvertMarimoFilesToDeepnoteFileOptions {
457
478
  projectName: string;
458
479
  }
459
480
  interface ConvertMarimoAppOptions {
460
- /** Custom ID generator function. Defaults to uuid v4. */
481
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
461
482
  idGenerator?: () => string;
462
483
  }
463
484
  interface MarimoAppInput {
@@ -497,7 +518,7 @@ declare function convertMarimoAppToBlocks(app: MarimoApp, options?: ConvertMarim
497
518
  interface ConvertMarimoAppsToDeepnoteOptions {
498
519
  /** Project name for the Deepnote file */
499
520
  projectName: string;
500
- /** Custom ID generator function. Defaults to uuid v4. */
521
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
501
522
  idGenerator?: () => string;
502
523
  }
503
524
  /**
@@ -520,7 +541,7 @@ interface ConvertPercentFilesToDeepnoteFileOptions {
520
541
  projectName: string;
521
542
  }
522
543
  interface ConvertPercentNotebookOptions {
523
- /** Custom ID generator function. Defaults to uuid v4. */
544
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
524
545
  idGenerator?: () => string;
525
546
  }
526
547
  interface PercentNotebookInput {
@@ -576,7 +597,7 @@ interface ConvertQuartoFilesToDeepnoteFileOptions {
576
597
  projectName: string;
577
598
  }
578
599
  interface ConvertQuartoDocumentOptions {
579
- /** Custom ID generator function. Defaults to uuid v4. */
600
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
580
601
  idGenerator?: () => string;
581
602
  }
582
603
  interface QuartoDocumentInput {
@@ -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
  /**
@@ -409,7 +430,7 @@ interface ConvertIpynbFilesToDeepnoteFileOptions {
409
430
  projectName: string;
410
431
  }
411
432
  interface ConvertJupyterNotebookOptions {
412
- /** Custom ID generator function. Defaults to uuid v4. */
433
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
413
434
  idGenerator?: () => string;
414
435
  }
415
436
  interface JupyterNotebookInput {
@@ -457,7 +478,7 @@ interface ConvertMarimoFilesToDeepnoteFileOptions {
457
478
  projectName: string;
458
479
  }
459
480
  interface ConvertMarimoAppOptions {
460
- /** Custom ID generator function. Defaults to uuid v4. */
481
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
461
482
  idGenerator?: () => string;
462
483
  }
463
484
  interface MarimoAppInput {
@@ -497,7 +518,7 @@ declare function convertMarimoAppToBlocks(app: MarimoApp, options?: ConvertMarim
497
518
  interface ConvertMarimoAppsToDeepnoteOptions {
498
519
  /** Project name for the Deepnote file */
499
520
  projectName: string;
500
- /** Custom ID generator function. Defaults to uuid v4. */
521
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
501
522
  idGenerator?: () => string;
502
523
  }
503
524
  /**
@@ -520,7 +541,7 @@ interface ConvertPercentFilesToDeepnoteFileOptions {
520
541
  projectName: string;
521
542
  }
522
543
  interface ConvertPercentNotebookOptions {
523
- /** Custom ID generator function. Defaults to uuid v4. */
544
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
524
545
  idGenerator?: () => string;
525
546
  }
526
547
  interface PercentNotebookInput {
@@ -576,7 +597,7 @@ interface ConvertQuartoFilesToDeepnoteFileOptions {
576
597
  projectName: string;
577
598
  }
578
599
  interface ConvertQuartoDocumentOptions {
579
- /** Custom ID generator function. Defaults to uuid v4. */
600
+ /** Custom ID generator function. Defaults to crypto.randomUUID(). */
580
601
  idGenerator?: () => string;
581
602
  }
582
603
  interface QuartoDocumentInput {
@@ -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 convertDeepnoteFileToJupyterFiles, N as convertDeepnoteToJupyterNotebooks, O as convertDeepnoteFileToMarimoFiles, 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 convertBlocksToJupyterNotebook, 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-oALQkXiP.js";
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 };
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs/promises";
2
2
  import { basename, dirname, extname, join } from "node:path";
3
3
  import { createMarkdown, createPythonCode, deepnoteBlockSchema, deserializeDeepnoteFile, environmentSchema, executionSchema } from "@deepnote/blocks";
4
- import { v4 } from "uuid";
4
+ import { randomUUID } from "node:crypto";
5
5
  import { parse, stringify } from "yaml";
6
6
 
7
7
  //#region src/utils.ts
@@ -98,7 +98,7 @@ function sortKeysAlphabetically(obj) {
98
98
  */
99
99
  function convertBlocksToJupyterNotebook(blocks, options) {
100
100
  return {
101
- cells: blocks.map((block) => convertBlockToCell$3(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
- function convertBlockToCell$3(block) {
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;
@@ -668,7 +688,7 @@ function detectFormat(filename, content) {
668
688
  * ```
669
689
  */
670
690
  function convertJupyterNotebookToBlocks(notebook, options) {
671
- const idGenerator = options?.idGenerator ?? v4;
691
+ const idGenerator = options?.idGenerator ?? randomUUID;
672
692
  return notebook.cells.map((cell, index) => convertCellToBlock$3(cell, index, idGenerator));
673
693
  }
674
694
  /**
@@ -692,13 +712,13 @@ function convertJupyterNotebooksToDeepnote(notebooks, options) {
692
712
  if (parsed.success) execution = parsed.data;
693
713
  }
694
714
  }
695
- const firstNotebookId = notebooks.length > 0 ? notebooks[0].notebook.metadata?.deepnote_notebook_id ?? v4() : void 0;
715
+ const firstNotebookId = notebooks.length > 0 ? notebooks[0].notebook.metadata?.deepnote_notebook_id ?? randomUUID() : void 0;
696
716
  const deepnoteFile = {
697
717
  environment,
698
718
  execution,
699
719
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
700
720
  project: {
701
- id: v4(),
721
+ id: randomUUID(),
702
722
  initNotebookId: firstNotebookId,
703
723
  integrations: [],
704
724
  name: options.projectName,
@@ -716,7 +736,7 @@ function convertJupyterNotebooksToDeepnote(notebooks, options) {
716
736
  const executionMode = notebook.metadata?.deepnote_execution_mode;
717
737
  const isModule = notebook.metadata?.deepnote_is_module;
718
738
  const workingDirectory = notebook.metadata?.deepnote_working_directory;
719
- const resolvedNotebookId = i === 0 && firstNotebookId ? firstNotebookId : notebookId ?? v4();
739
+ const resolvedNotebookId = i === 0 && firstNotebookId ? firstNotebookId : notebookId ?? randomUUID();
720
740
  deepnoteFile.project.notebooks.push({
721
741
  blocks,
722
742
  executionMode: executionMode ?? "block",
@@ -971,7 +991,7 @@ function parseMarimoFormat(content) {
971
991
  * @returns Array of DeepnoteBlock objects
972
992
  */
973
993
  function convertMarimoAppToBlocks(app, options) {
974
- const idGenerator = options?.idGenerator ?? v4;
994
+ const idGenerator = options?.idGenerator ?? randomUUID;
975
995
  return app.cells.map((cell, index) => convertCellToBlock$2(cell, index, idGenerator));
976
996
  }
977
997
  /**
@@ -983,7 +1003,7 @@ function convertMarimoAppToBlocks(app, options) {
983
1003
  * @returns A DeepnoteFile object
984
1004
  */
985
1005
  function convertMarimoAppsToDeepnote(apps, options) {
986
- const idGenerator = options.idGenerator ?? v4;
1006
+ const idGenerator = options.idGenerator ?? randomUUID;
987
1007
  const firstNotebookId = apps.length > 0 ? idGenerator() : void 0;
988
1008
  const deepnoteFile = {
989
1009
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
@@ -1141,7 +1161,7 @@ function parsePercentFormat(content) {
1141
1161
  * @returns Array of DeepnoteBlock objects
1142
1162
  */
1143
1163
  function convertPercentNotebookToBlocks(notebook, options) {
1144
- const idGenerator = options?.idGenerator ?? v4;
1164
+ const idGenerator = options?.idGenerator ?? randomUUID;
1145
1165
  return notebook.cells.map((cell, index) => convertCellToBlock$1(cell, index, idGenerator));
1146
1166
  }
1147
1167
  /**
@@ -1153,11 +1173,11 @@ function convertPercentNotebookToBlocks(notebook, options) {
1153
1173
  * @returns A DeepnoteFile object
1154
1174
  */
1155
1175
  function convertPercentNotebooksToDeepnote(notebooks, options) {
1156
- const firstNotebookId = notebooks.length > 0 ? v4() : void 0;
1176
+ const firstNotebookId = notebooks.length > 0 ? randomUUID() : void 0;
1157
1177
  const deepnoteFile = {
1158
1178
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
1159
1179
  project: {
1160
- id: v4(),
1180
+ id: randomUUID(),
1161
1181
  initNotebookId: firstNotebookId,
1162
1182
  integrations: [],
1163
1183
  name: options.projectName,
@@ -1170,7 +1190,7 @@ function convertPercentNotebooksToDeepnote(notebooks, options) {
1170
1190
  const { filename, notebook } = notebooks[i];
1171
1191
  const filenameWithoutExt = basename(filename, extname(filename)) || "Untitled notebook";
1172
1192
  const blocks = convertPercentNotebookToBlocks(notebook);
1173
- const notebookId = i === 0 && firstNotebookId ? firstNotebookId : v4();
1193
+ const notebookId = i === 0 && firstNotebookId ? firstNotebookId : randomUUID();
1174
1194
  deepnoteFile.project.notebooks.push({
1175
1195
  blocks,
1176
1196
  executionMode: "block",
@@ -1392,7 +1412,7 @@ function parseQuartoCellOptions(content) {
1392
1412
  * @returns Array of DeepnoteBlock objects
1393
1413
  */
1394
1414
  function convertQuartoDocumentToBlocks(document, options) {
1395
- const idGenerator = options?.idGenerator ?? v4;
1415
+ const idGenerator = options?.idGenerator ?? randomUUID;
1396
1416
  const blocks = [];
1397
1417
  if (document.frontmatter?.title) blocks.push({
1398
1418
  blockGroup: idGenerator(),
@@ -1414,11 +1434,11 @@ function convertQuartoDocumentToBlocks(document, options) {
1414
1434
  * @returns A DeepnoteFile object
1415
1435
  */
1416
1436
  function convertQuartoDocumentsToDeepnote(documents, options) {
1417
- const firstNotebookId = documents.length > 0 ? v4() : void 0;
1437
+ const firstNotebookId = documents.length > 0 ? randomUUID() : void 0;
1418
1438
  const deepnoteFile = {
1419
1439
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
1420
1440
  project: {
1421
- id: v4(),
1441
+ id: randomUUID(),
1422
1442
  initNotebookId: firstNotebookId,
1423
1443
  integrations: [],
1424
1444
  name: options.projectName,
@@ -1432,7 +1452,7 @@ function convertQuartoDocumentsToDeepnote(documents, options) {
1432
1452
  const filenameWithoutExt = basename(filename, extname(filename)) || "Untitled notebook";
1433
1453
  const notebookName = document.frontmatter?.title || filenameWithoutExt;
1434
1454
  const blocks = convertQuartoDocumentToBlocks(document);
1435
- const notebookId = i === 0 && firstNotebookId ? firstNotebookId : v4();
1455
+ const notebookId = i === 0 && firstNotebookId ? firstNotebookId : randomUUID();
1436
1456
  deepnoteFile.project.notebooks.push({
1437
1457
  blocks,
1438
1458
  executionMode: "block",
@@ -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, convertDeepnoteFileToJupyterFiles as M, convertDeepnoteToJupyterNotebooks as N, convertDeepnoteFileToMarimoFiles as O, 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, convertBlocksToJupyterNotebook 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 };
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 };
@@ -27,8 +27,8 @@ let node_path = require("node:path");
27
27
  node_path = __toESM(node_path);
28
28
  let __deepnote_blocks = require("@deepnote/blocks");
29
29
  __deepnote_blocks = __toESM(__deepnote_blocks);
30
- let uuid = require("uuid");
31
- uuid = __toESM(uuid);
30
+ let node_crypto = require("node:crypto");
31
+ node_crypto = __toESM(node_crypto);
32
32
  let yaml = require("yaml");
33
33
  yaml = __toESM(yaml);
34
34
 
@@ -126,7 +126,7 @@ function sortKeysAlphabetically(obj) {
126
126
  */
127
127
  function convertBlocksToJupyterNotebook(blocks, options) {
128
128
  return {
129
- cells: blocks.map((block) => convertBlockToCell$3(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
- function convertBlockToCell$3(block) {
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;
@@ -696,7 +716,7 @@ function detectFormat(filename, content) {
696
716
  * ```
697
717
  */
698
718
  function convertJupyterNotebookToBlocks(notebook, options) {
699
- const idGenerator = options?.idGenerator ?? uuid.v4;
719
+ const idGenerator = options?.idGenerator ?? node_crypto.randomUUID;
700
720
  return notebook.cells.map((cell, index) => convertCellToBlock$3(cell, index, idGenerator));
701
721
  }
702
722
  /**
@@ -720,13 +740,13 @@ function convertJupyterNotebooksToDeepnote(notebooks, options) {
720
740
  if (parsed.success) execution = parsed.data;
721
741
  }
722
742
  }
723
- const firstNotebookId = notebooks.length > 0 ? notebooks[0].notebook.metadata?.deepnote_notebook_id ?? (0, uuid.v4)() : void 0;
743
+ const firstNotebookId = notebooks.length > 0 ? notebooks[0].notebook.metadata?.deepnote_notebook_id ?? (0, node_crypto.randomUUID)() : void 0;
724
744
  const deepnoteFile = {
725
745
  environment,
726
746
  execution,
727
747
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
728
748
  project: {
729
- id: (0, uuid.v4)(),
749
+ id: (0, node_crypto.randomUUID)(),
730
750
  initNotebookId: firstNotebookId,
731
751
  integrations: [],
732
752
  name: options.projectName,
@@ -744,7 +764,7 @@ function convertJupyterNotebooksToDeepnote(notebooks, options) {
744
764
  const executionMode = notebook.metadata?.deepnote_execution_mode;
745
765
  const isModule = notebook.metadata?.deepnote_is_module;
746
766
  const workingDirectory = notebook.metadata?.deepnote_working_directory;
747
- const resolvedNotebookId = i === 0 && firstNotebookId ? firstNotebookId : notebookId ?? (0, uuid.v4)();
767
+ const resolvedNotebookId = i === 0 && firstNotebookId ? firstNotebookId : notebookId ?? (0, node_crypto.randomUUID)();
748
768
  deepnoteFile.project.notebooks.push({
749
769
  blocks,
750
770
  executionMode: executionMode ?? "block",
@@ -999,7 +1019,7 @@ function parseMarimoFormat(content) {
999
1019
  * @returns Array of DeepnoteBlock objects
1000
1020
  */
1001
1021
  function convertMarimoAppToBlocks(app, options) {
1002
- const idGenerator = options?.idGenerator ?? uuid.v4;
1022
+ const idGenerator = options?.idGenerator ?? node_crypto.randomUUID;
1003
1023
  return app.cells.map((cell, index) => convertCellToBlock$2(cell, index, idGenerator));
1004
1024
  }
1005
1025
  /**
@@ -1011,7 +1031,7 @@ function convertMarimoAppToBlocks(app, options) {
1011
1031
  * @returns A DeepnoteFile object
1012
1032
  */
1013
1033
  function convertMarimoAppsToDeepnote(apps, options) {
1014
- const idGenerator = options.idGenerator ?? uuid.v4;
1034
+ const idGenerator = options.idGenerator ?? node_crypto.randomUUID;
1015
1035
  const firstNotebookId = apps.length > 0 ? idGenerator() : void 0;
1016
1036
  const deepnoteFile = {
1017
1037
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
@@ -1169,7 +1189,7 @@ function parsePercentFormat(content) {
1169
1189
  * @returns Array of DeepnoteBlock objects
1170
1190
  */
1171
1191
  function convertPercentNotebookToBlocks(notebook, options) {
1172
- const idGenerator = options?.idGenerator ?? uuid.v4;
1192
+ const idGenerator = options?.idGenerator ?? node_crypto.randomUUID;
1173
1193
  return notebook.cells.map((cell, index) => convertCellToBlock$1(cell, index, idGenerator));
1174
1194
  }
1175
1195
  /**
@@ -1181,11 +1201,11 @@ function convertPercentNotebookToBlocks(notebook, options) {
1181
1201
  * @returns A DeepnoteFile object
1182
1202
  */
1183
1203
  function convertPercentNotebooksToDeepnote(notebooks, options) {
1184
- const firstNotebookId = notebooks.length > 0 ? (0, uuid.v4)() : void 0;
1204
+ const firstNotebookId = notebooks.length > 0 ? (0, node_crypto.randomUUID)() : void 0;
1185
1205
  const deepnoteFile = {
1186
1206
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
1187
1207
  project: {
1188
- id: (0, uuid.v4)(),
1208
+ id: (0, node_crypto.randomUUID)(),
1189
1209
  initNotebookId: firstNotebookId,
1190
1210
  integrations: [],
1191
1211
  name: options.projectName,
@@ -1198,7 +1218,7 @@ function convertPercentNotebooksToDeepnote(notebooks, options) {
1198
1218
  const { filename, notebook } = notebooks[i];
1199
1219
  const filenameWithoutExt = (0, node_path.basename)(filename, (0, node_path.extname)(filename)) || "Untitled notebook";
1200
1220
  const blocks = convertPercentNotebookToBlocks(notebook);
1201
- const notebookId = i === 0 && firstNotebookId ? firstNotebookId : (0, uuid.v4)();
1221
+ const notebookId = i === 0 && firstNotebookId ? firstNotebookId : (0, node_crypto.randomUUID)();
1202
1222
  deepnoteFile.project.notebooks.push({
1203
1223
  blocks,
1204
1224
  executionMode: "block",
@@ -1420,7 +1440,7 @@ function parseQuartoCellOptions(content) {
1420
1440
  * @returns Array of DeepnoteBlock objects
1421
1441
  */
1422
1442
  function convertQuartoDocumentToBlocks(document, options) {
1423
- const idGenerator = options?.idGenerator ?? uuid.v4;
1443
+ const idGenerator = options?.idGenerator ?? node_crypto.randomUUID;
1424
1444
  const blocks = [];
1425
1445
  if (document.frontmatter?.title) blocks.push({
1426
1446
  blockGroup: idGenerator(),
@@ -1442,11 +1462,11 @@ function convertQuartoDocumentToBlocks(document, options) {
1442
1462
  * @returns A DeepnoteFile object
1443
1463
  */
1444
1464
  function convertQuartoDocumentsToDeepnote(documents, options) {
1445
- const firstNotebookId = documents.length > 0 ? (0, uuid.v4)() : void 0;
1465
+ const firstNotebookId = documents.length > 0 ? (0, node_crypto.randomUUID)() : void 0;
1446
1466
  const deepnoteFile = {
1447
1467
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
1448
1468
  project: {
1449
- id: (0, uuid.v4)(),
1469
+ id: (0, node_crypto.randomUUID)(),
1450
1470
  initNotebookId: firstNotebookId,
1451
1471
  integrations: [],
1452
1472
  name: options.projectName,
@@ -1460,7 +1480,7 @@ function convertQuartoDocumentsToDeepnote(documents, options) {
1460
1480
  const filenameWithoutExt = (0, node_path.basename)(filename, (0, node_path.extname)(filename)) || "Untitled notebook";
1461
1481
  const notebookName = document.frontmatter?.title || filenameWithoutExt;
1462
1482
  const blocks = convertQuartoDocumentToBlocks(document);
1463
- const notebookId = i === 0 && firstNotebookId ? firstNotebookId : (0, uuid.v4)();
1483
+ const notebookId = i === 0 && firstNotebookId ? firstNotebookId : (0, node_crypto.randomUUID)();
1464
1484
  deepnoteFile.project.notebooks.push({
1465
1485
  blocks,
1466
1486
  executionMode: "block",
@@ -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 () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnote/convert",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -33,7 +33,6 @@
33
33
  "chalk": "^5.6.2",
34
34
  "cleye": "^2.0.0",
35
35
  "ora": "^9.0.0",
36
- "uuid": "^13.0.0",
37
36
  "yaml": "^2.8.1",
38
37
  "@deepnote/blocks": "3.0.1"
39
38
  },