@deepnote/convert 3.1.0 → 3.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-BR6PqlNA.cjs');
2
+ const require_src = require('./src-BLBMaZtg.cjs');
3
3
  let cleye = require("cleye");
4
4
  cleye = require_src.__toESM(cleye);
5
5
  let node_fs_promises = require("node:fs/promises");
@@ -12,8 +12,6 @@ let chalk = require("chalk");
12
12
  chalk = require_src.__toESM(chalk);
13
13
  let ora = require("ora");
14
14
  ora = require_src.__toESM(ora);
15
- let yaml = require("yaml");
16
- yaml = require_src.__toESM(yaml);
17
15
 
18
16
  //#region src/cli.ts
19
17
  async function convert(options) {
@@ -218,7 +216,7 @@ async function convertDeepnoteToFormat(absolutePath, outputFormat, customOutputP
218
216
  const tempDir = await node_fs_promises.default.mkdtemp((0, node_path.resolve)((0, node_path.dirname)(absolutePath), ".deepnote-merge-"));
219
217
  const tempPath = (0, node_path.resolve)(tempDir, `${filenameWithoutExtension}.merged.deepnote`);
220
218
  try {
221
- const mergedYaml = (0, yaml.stringify)(deepnoteFile);
219
+ const mergedYaml = (0, __deepnote_blocks.serializeDeepnoteFile)(deepnoteFile);
222
220
  await node_fs_promises.default.writeFile(tempPath, mergedYaml, "utf-8");
223
221
  switch (outputFormat) {
224
222
  case "jupyter":
package/dist/bin.js CHANGED
@@ -1,12 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { G as convertDeepnoteFileToPercentFiles, I as readAndConvertIpynbFiles, R as isMarimoContent, S as mergeSnapshotIntoSource, T as loadLatestSnapshot, V as convertDeepnoteFileToQuartoFiles, Y as convertDeepnoteFileToMarimoFiles, d as readAndConvertPercentFiles, g as readAndConvertMarimoFiles, it as convertDeepnoteFileToJupyterFiles, o as readAndConvertQuartoFiles, t as writeDeepnoteFile, tt as UnsupportedFormatError, z as isPercentContent } from "./src-BN4Mwc-V.js";
2
+ import { G as convertDeepnoteFileToPercentFiles, I as readAndConvertIpynbFiles, R as isMarimoContent, S as mergeSnapshotIntoSource, T as loadLatestSnapshot, V as convertDeepnoteFileToQuartoFiles, Y as convertDeepnoteFileToMarimoFiles, d as readAndConvertPercentFiles, g as readAndConvertMarimoFiles, it as convertDeepnoteFileToJupyterFiles, o as readAndConvertQuartoFiles, t as writeDeepnoteFile, tt as UnsupportedFormatError, z as isPercentContent } from "./src-BS7a6Oo0.js";
3
3
  import { cli } from "cleye";
4
4
  import fs from "node:fs/promises";
5
5
  import { basename, dirname, extname, resolve } from "node:path";
6
- import { deserializeDeepnoteFile } from "@deepnote/blocks";
6
+ import { deserializeDeepnoteFile, serializeDeepnoteFile } from "@deepnote/blocks";
7
7
  import chalk from "chalk";
8
8
  import ora from "ora";
9
- import { stringify } from "yaml";
10
9
 
11
10
  //#region src/cli.ts
12
11
  async function convert(options) {
@@ -211,7 +210,7 @@ async function convertDeepnoteToFormat(absolutePath, outputFormat, customOutputP
211
210
  const tempDir = await fs.mkdtemp(resolve(dirname(absolutePath), ".deepnote-merge-"));
212
211
  const tempPath = resolve(tempDir, `${filenameWithoutExtension}.merged.deepnote`);
213
212
  try {
214
- const mergedYaml = stringify(deepnoteFile);
213
+ const mergedYaml = serializeDeepnoteFile(deepnoteFile);
215
214
  await fs.writeFile(tempPath, mergedYaml, "utf-8");
216
215
  switch (outputFormat) {
217
216
  case "jupyter":
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_src = require('./src-BR6PqlNA.cjs');
1
+ const require_src = require('./src-BLBMaZtg.cjs');
2
2
 
3
3
  exports.FileReadError = require_src.FileReadError;
4
4
  exports.FileWriteError = require_src.FileWriteError;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as FileWriteError, A as addContentHashes, B as convertBlocksToQuartoDocument, C as findSnapshotsForProject, D as parseSnapshotFilename, E as loadSnapshotFile, F as convertJupyterNotebooksToDeepnote, G as convertDeepnoteFileToPercentFiles, H as convertDeepnoteToQuartoDocuments, I as readAndConvertIpynbFiles, J as convertBlocksToMarimoApp, K as convertDeepnoteToPercentNotebooks, L as detectFormat, M as computeSnapshotHash, N as convertIpynbFilesToDeepnoteFile, O as parseSourceFilePath, P as convertJupyterNotebookToBlocks, Q as FileReadError, S as mergeSnapshotIntoSource, T as loadLatestSnapshot, U as serializeQuartoFormat, V as convertDeepnoteFileToQuartoFiles, W as convertBlocksToPercentNotebook, X as convertDeepnoteToMarimoApps, Y as convertDeepnoteFileToMarimoFiles, Z as serializeMarimoFormat, _ as generateSnapshotFilename, a as parseQuartoFormat, at as convertDeepnoteToJupyterNotebooks, b as splitDeepnoteFile, c as convertPercentNotebookToBlocks, d as readAndConvertPercentFiles, et as JsonParseError, f as convertMarimoAppToBlocks, g as readAndConvertMarimoFiles, h as parseMarimoFormat, i as convertQuartoFilesToDeepnoteFile, it as convertDeepnoteFileToJupyterFiles, j as computeContentHash, k as snapshotExists, l as convertPercentNotebooksToDeepnote, m as convertMarimoFilesToDeepnoteFile, n as convertQuartoDocumentToBlocks, nt as convertBlockToJupyterCell, o as readAndConvertQuartoFiles, p as convertMarimoAppsToDeepnote, q as serializePercentFormat, r as convertQuartoDocumentsToDeepnote, rt as convertBlocksToJupyterNotebook, s as convertPercentFilesToDeepnoteFile, t as writeDeepnoteFile, tt as UnsupportedFormatError, u as parsePercentFormat, v as hasOutputs, w as getSnapshotDir, x as countBlocksWithOutputs, y as slugifyProjectName } from "./src-BN4Mwc-V.js";
1
+ import { $ as FileWriteError, A as addContentHashes, B as convertBlocksToQuartoDocument, C as findSnapshotsForProject, D as parseSnapshotFilename, E as loadSnapshotFile, F as convertJupyterNotebooksToDeepnote, G as convertDeepnoteFileToPercentFiles, H as convertDeepnoteToQuartoDocuments, I as readAndConvertIpynbFiles, J as convertBlocksToMarimoApp, K as convertDeepnoteToPercentNotebooks, L as detectFormat, M as computeSnapshotHash, N as convertIpynbFilesToDeepnoteFile, O as parseSourceFilePath, P as convertJupyterNotebookToBlocks, Q as FileReadError, S as mergeSnapshotIntoSource, T as loadLatestSnapshot, U as serializeQuartoFormat, V as convertDeepnoteFileToQuartoFiles, W as convertBlocksToPercentNotebook, X as convertDeepnoteToMarimoApps, Y as convertDeepnoteFileToMarimoFiles, Z as serializeMarimoFormat, _ as generateSnapshotFilename, a as parseQuartoFormat, at as convertDeepnoteToJupyterNotebooks, b as splitDeepnoteFile, c as convertPercentNotebookToBlocks, d as readAndConvertPercentFiles, et as JsonParseError, f as convertMarimoAppToBlocks, g as readAndConvertMarimoFiles, h as parseMarimoFormat, i as convertQuartoFilesToDeepnoteFile, it as convertDeepnoteFileToJupyterFiles, j as computeContentHash, k as snapshotExists, l as convertPercentNotebooksToDeepnote, m as convertMarimoFilesToDeepnoteFile, n as convertQuartoDocumentToBlocks, nt as convertBlockToJupyterCell, o as readAndConvertQuartoFiles, p as convertMarimoAppsToDeepnote, q as serializePercentFormat, r as convertQuartoDocumentsToDeepnote, rt as convertBlocksToJupyterNotebook, s as convertPercentFilesToDeepnoteFile, t as writeDeepnoteFile, tt as UnsupportedFormatError, u as parsePercentFormat, v as hasOutputs, w as getSnapshotDir, x as countBlocksWithOutputs, y as slugifyProjectName } from "./src-BS7a6Oo0.js";
2
2
 
3
3
  export { FileReadError, FileWriteError, JsonParseError, UnsupportedFormatError, addContentHashes, computeContentHash, computeSnapshotHash, convertBlockToJupyterCell, convertBlocksToJupyterNotebook, convertBlocksToMarimoApp, convertBlocksToPercentNotebook, convertBlocksToQuartoDocument, convertDeepnoteFileToJupyterFiles, convertDeepnoteFileToMarimoFiles, convertDeepnoteFileToPercentFiles, convertDeepnoteFileToQuartoFiles, convertDeepnoteToJupyterNotebooks, convertDeepnoteToMarimoApps, convertDeepnoteToPercentNotebooks, convertDeepnoteToQuartoDocuments, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote, convertMarimoAppToBlocks, convertMarimoAppsToDeepnote, convertMarimoFilesToDeepnoteFile, convertPercentFilesToDeepnoteFile, convertPercentNotebookToBlocks, convertPercentNotebooksToDeepnote, convertQuartoDocumentToBlocks, convertQuartoDocumentsToDeepnote, convertQuartoFilesToDeepnoteFile, countBlocksWithOutputs, detectFormat, findSnapshotsForProject, generateSnapshotFilename, getSnapshotDir, hasOutputs, loadLatestSnapshot, loadSnapshotFile, mergeSnapshotIntoSource, parseMarimoFormat, parsePercentFormat, parseQuartoFormat, parseSnapshotFilename, parseSourceFilePath, readAndConvertIpynbFiles, readAndConvertMarimoFiles, readAndConvertPercentFiles, readAndConvertQuartoFiles, serializeMarimoFormat, serializePercentFormat, serializeQuartoFormat, slugifyProjectName, snapshotExists, splitDeepnoteFile, writeDeepnoteFile };
@@ -27,37 +27,13 @@ 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 yaml = require("yaml");
31
- yaml = __toESM(yaml);
32
30
  let node_crypto = require("node:crypto");
33
31
  node_crypto = __toESM(node_crypto);
32
+ let yaml = require("yaml");
33
+ yaml = __toESM(yaml);
34
34
 
35
35
  //#region src/utils.ts
36
36
  /**
37
- * Creates a sorting key for Deepnote blocks.
38
- * Uses a base-36 encoding to generate compact, sortable keys.
39
- *
40
- * @param index - The zero-based index of the block
41
- * @returns A sortable string key
42
- */
43
- function createSortingKey(index) {
44
- const maxLength = 6;
45
- const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
46
- const base = 36;
47
- if (index < 0) throw new __deepnote_blocks.InvalidValueError("Index must be non-negative", { value: index });
48
- let result = "";
49
- let num = index + 1;
50
- let iterations = 0;
51
- while (num > 0 && iterations < maxLength) {
52
- num--;
53
- result = chars[num % base] + result;
54
- num = Math.floor(num / base);
55
- iterations++;
56
- }
57
- if (num > 0) throw new __deepnote_blocks.InvalidValueError(`Index ${index} exceeds maximum key length of ${maxLength}`, { value: index });
58
- return result;
59
- }
60
- /**
61
37
  * Sanitizes a filename by removing invalid characters and replacing spaces.
62
38
  *
63
39
  * @param name - The original filename
@@ -876,7 +852,7 @@ async function readAndConvertIpynbFiles(inputFilePaths, options) {
876
852
  * Converts multiple Jupyter Notebook (.ipynb) files into a single Deepnote project file.
877
853
  */
878
854
  async function convertIpynbFilesToDeepnoteFile(inputFilePaths, options) {
879
- const yamlContent = (0, yaml.stringify)(await readAndConvertIpynbFiles(inputFilePaths, { projectName: options.projectName }));
855
+ const yamlContent = (0, __deepnote_blocks.serializeDeepnoteFile)(await readAndConvertIpynbFiles(inputFilePaths, { projectName: options.projectName }));
880
856
  const parentDir = (0, node_path.dirname)(options.outputPath);
881
857
  await node_fs_promises.default.mkdir(parentDir, { recursive: true });
882
858
  await node_fs_promises.default.writeFile(options.outputPath, yamlContent, "utf-8");
@@ -938,7 +914,7 @@ function convertCellToBlock$3(cell, index, idGenerator) {
938
914
  id: cellId ?? idGenerator(),
939
915
  metadata: originalMetadata,
940
916
  ...hasOutputs$1 ? { outputs: cell.outputs } : {},
941
- sortingKey: sortingKey ?? createSortingKey(index),
917
+ sortingKey: sortingKey ?? (0, __deepnote_blocks.generateSortingKey)(index),
942
918
  type: blockType
943
919
  }));
944
920
  }
@@ -1682,7 +1658,7 @@ async function convertMarimoFilesToDeepnoteFile(inputFilePaths, options) {
1682
1658
  filePath
1683
1659
  });
1684
1660
  }
1685
- const yamlContent = (0, yaml.stringify)(convertMarimoAppsToDeepnoteFile(apps, { projectName: options.projectName }));
1661
+ const yamlContent = (0, __deepnote_blocks.serializeDeepnoteFile)(convertMarimoAppsToDeepnoteFile(apps, { projectName: options.projectName }));
1686
1662
  const parentDir = (0, node_path.dirname)(options.outputPath);
1687
1663
  await node_fs_promises.default.mkdir(parentDir, { recursive: true });
1688
1664
  await node_fs_promises.default.writeFile(options.outputPath, yamlContent, "utf-8");
@@ -1704,7 +1680,7 @@ function convertCellToBlock$2(cell, index, idGenerator, outputs) {
1704
1680
  content: cell.content,
1705
1681
  id: idGenerator(),
1706
1682
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
1707
- sortingKey: createSortingKey(index),
1683
+ sortingKey: (0, __deepnote_blocks.generateSortingKey)(index),
1708
1684
  type: blockType,
1709
1685
  ...outputs && outputs.length > 0 && (blockType === "code" || blockType === "sql") ? { outputs } : {}
1710
1686
  };
@@ -1855,7 +1831,7 @@ async function readAndConvertPercentFiles(inputFilePaths, options) {
1855
1831
  * Converts multiple percent format (.py) files into a single Deepnote project file.
1856
1832
  */
1857
1833
  async function convertPercentFilesToDeepnoteFile(inputFilePaths, options) {
1858
- const yamlContent = (0, yaml.stringify)(await readAndConvertPercentFiles(inputFilePaths, { projectName: options.projectName }));
1834
+ const yamlContent = (0, __deepnote_blocks.serializeDeepnoteFile)(await readAndConvertPercentFiles(inputFilePaths, { projectName: options.projectName }));
1859
1835
  const parentDir = (0, node_path.dirname)(options.outputPath);
1860
1836
  await node_fs_promises.default.mkdir(parentDir, { recursive: true });
1861
1837
  await node_fs_promises.default.writeFile(options.outputPath, yamlContent, "utf-8");
@@ -1871,7 +1847,7 @@ function convertCellToBlock$1(cell, index, idGenerator) {
1871
1847
  content: cell.content,
1872
1848
  id: idGenerator(),
1873
1849
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
1874
- sortingKey: createSortingKey(index),
1850
+ sortingKey: (0, __deepnote_blocks.generateSortingKey)(index),
1875
1851
  type: blockType
1876
1852
  };
1877
1853
  }
@@ -2061,7 +2037,7 @@ function convertQuartoDocumentToBlocks(document, options) {
2061
2037
  content: `# ${document.frontmatter.title}`,
2062
2038
  id: idGenerator(),
2063
2039
  metadata: {},
2064
- sortingKey: createSortingKey(blocks.length),
2040
+ sortingKey: (0, __deepnote_blocks.generateSortingKey)(blocks.length),
2065
2041
  type: "markdown"
2066
2042
  });
2067
2043
  for (const cell of document.cells) blocks.push(convertCellToBlock(cell, blocks.length, idGenerator));
@@ -2128,7 +2104,7 @@ async function readAndConvertQuartoFiles(inputFilePaths, options) {
2128
2104
  * Converts multiple Quarto (.qmd) files into a single Deepnote project file.
2129
2105
  */
2130
2106
  async function convertQuartoFilesToDeepnoteFile(inputFilePaths, options) {
2131
- const yamlContent = (0, yaml.stringify)(await readAndConvertQuartoFiles(inputFilePaths, { projectName: options.projectName }));
2107
+ const yamlContent = (0, __deepnote_blocks.serializeDeepnoteFile)(await readAndConvertQuartoFiles(inputFilePaths, { projectName: options.projectName }));
2132
2108
  const parentDir = (0, node_path.dirname)(options.outputPath);
2133
2109
  await node_fs_promises.default.mkdir(parentDir, { recursive: true });
2134
2110
  await node_fs_promises.default.writeFile(options.outputPath, yamlContent, "utf-8");
@@ -2149,7 +2125,7 @@ function convertCellToBlock(cell, index, idGenerator) {
2149
2125
  content: cell.content,
2150
2126
  id: idGenerator(),
2151
2127
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
2152
- sortingKey: createSortingKey(index),
2128
+ sortingKey: (0, __deepnote_blocks.generateSortingKey)(index),
2153
2129
  type: blockType
2154
2130
  };
2155
2131
  }
@@ -2174,15 +2150,15 @@ async function writeDeepnoteFile(options) {
2174
2150
  const parentDir = (0, node_path.dirname)(outputPath);
2175
2151
  await node_fs_promises.default.mkdir(parentDir, { recursive: true });
2176
2152
  if (singleFile || !hasOutputs(file)) {
2177
- const yamlContent = (0, yaml.stringify)(file);
2153
+ const yamlContent = (0, __deepnote_blocks.serializeDeepnoteFile)(file);
2178
2154
  await node_fs_promises.default.writeFile(outputPath, yamlContent, "utf-8");
2179
2155
  return { sourcePath: outputPath };
2180
2156
  }
2181
2157
  const { source, snapshot } = splitDeepnoteFile(file);
2182
2158
  const snapshotDir = getSnapshotDir(outputPath);
2183
2159
  const snapshotPath = (0, node_path.resolve)(snapshotDir, generateSnapshotFilename(slugifyProjectName(projectName) || "project", file.project.id));
2184
- const sourceYaml = (0, yaml.stringify)(source);
2185
- const snapshotYaml = (0, yaml.stringify)(snapshot);
2160
+ const sourceYaml = (0, __deepnote_blocks.serializeDeepnoteFile)(source);
2161
+ const snapshotYaml = (0, __deepnote_blocks.serializeDeepnoteSnapshot)(snapshot);
2186
2162
  await node_fs_promises.default.mkdir(snapshotDir, { recursive: true });
2187
2163
  await Promise.all([node_fs_promises.default.writeFile(outputPath, sourceYaml, "utf-8"), node_fs_promises.default.writeFile(snapshotPath, snapshotYaml, "utf-8")]);
2188
2164
  return {
@@ -1,35 +1,11 @@
1
1
  import fs from "node:fs/promises";
2
2
  import { basename, dirname, extname, join, resolve } from "node:path";
3
- import { DeepnoteError, InvalidValueError, ParseError, createMarkdown, createPythonCode, deepnoteBlockSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionSchema, isExecutableBlockType } from "@deepnote/blocks";
4
- import { parse, stringify } from "yaml";
3
+ import { DeepnoteError, ParseError, createMarkdown, createPythonCode, deepnoteBlockSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionSchema, generateSortingKey, isExecutableBlockType, serializeDeepnoteFile, serializeDeepnoteSnapshot } from "@deepnote/blocks";
5
4
  import { createHash, randomUUID } from "node:crypto";
5
+ import { parse } from "yaml";
6
6
 
7
7
  //#region src/utils.ts
8
8
  /**
9
- * Creates a sorting key for Deepnote blocks.
10
- * Uses a base-36 encoding to generate compact, sortable keys.
11
- *
12
- * @param index - The zero-based index of the block
13
- * @returns A sortable string key
14
- */
15
- function createSortingKey(index) {
16
- const maxLength = 6;
17
- const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
18
- const base = 36;
19
- if (index < 0) throw new InvalidValueError("Index must be non-negative", { value: index });
20
- let result = "";
21
- let num = index + 1;
22
- let iterations = 0;
23
- while (num > 0 && iterations < maxLength) {
24
- num--;
25
- result = chars[num % base] + result;
26
- num = Math.floor(num / base);
27
- iterations++;
28
- }
29
- if (num > 0) throw new InvalidValueError(`Index ${index} exceeds maximum key length of ${maxLength}`, { value: index });
30
- return result;
31
- }
32
- /**
33
9
  * Sanitizes a filename by removing invalid characters and replacing spaces.
34
10
  *
35
11
  * @param name - The original filename
@@ -848,7 +824,7 @@ async function readAndConvertIpynbFiles(inputFilePaths, options) {
848
824
  * Converts multiple Jupyter Notebook (.ipynb) files into a single Deepnote project file.
849
825
  */
850
826
  async function convertIpynbFilesToDeepnoteFile(inputFilePaths, options) {
851
- const yamlContent = stringify(await readAndConvertIpynbFiles(inputFilePaths, { projectName: options.projectName }));
827
+ const yamlContent = serializeDeepnoteFile(await readAndConvertIpynbFiles(inputFilePaths, { projectName: options.projectName }));
852
828
  const parentDir = dirname(options.outputPath);
853
829
  await fs.mkdir(parentDir, { recursive: true });
854
830
  await fs.writeFile(options.outputPath, yamlContent, "utf-8");
@@ -910,7 +886,7 @@ function convertCellToBlock$3(cell, index, idGenerator) {
910
886
  id: cellId ?? idGenerator(),
911
887
  metadata: originalMetadata,
912
888
  ...hasOutputs$1 ? { outputs: cell.outputs } : {},
913
- sortingKey: sortingKey ?? createSortingKey(index),
889
+ sortingKey: sortingKey ?? generateSortingKey(index),
914
890
  type: blockType
915
891
  }));
916
892
  }
@@ -1654,7 +1630,7 @@ async function convertMarimoFilesToDeepnoteFile(inputFilePaths, options) {
1654
1630
  filePath
1655
1631
  });
1656
1632
  }
1657
- const yamlContent = stringify(convertMarimoAppsToDeepnoteFile(apps, { projectName: options.projectName }));
1633
+ const yamlContent = serializeDeepnoteFile(convertMarimoAppsToDeepnoteFile(apps, { projectName: options.projectName }));
1658
1634
  const parentDir = dirname(options.outputPath);
1659
1635
  await fs.mkdir(parentDir, { recursive: true });
1660
1636
  await fs.writeFile(options.outputPath, yamlContent, "utf-8");
@@ -1676,7 +1652,7 @@ function convertCellToBlock$2(cell, index, idGenerator, outputs) {
1676
1652
  content: cell.content,
1677
1653
  id: idGenerator(),
1678
1654
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
1679
- sortingKey: createSortingKey(index),
1655
+ sortingKey: generateSortingKey(index),
1680
1656
  type: blockType,
1681
1657
  ...outputs && outputs.length > 0 && (blockType === "code" || blockType === "sql") ? { outputs } : {}
1682
1658
  };
@@ -1827,7 +1803,7 @@ async function readAndConvertPercentFiles(inputFilePaths, options) {
1827
1803
  * Converts multiple percent format (.py) files into a single Deepnote project file.
1828
1804
  */
1829
1805
  async function convertPercentFilesToDeepnoteFile(inputFilePaths, options) {
1830
- const yamlContent = stringify(await readAndConvertPercentFiles(inputFilePaths, { projectName: options.projectName }));
1806
+ const yamlContent = serializeDeepnoteFile(await readAndConvertPercentFiles(inputFilePaths, { projectName: options.projectName }));
1831
1807
  const parentDir = dirname(options.outputPath);
1832
1808
  await fs.mkdir(parentDir, { recursive: true });
1833
1809
  await fs.writeFile(options.outputPath, yamlContent, "utf-8");
@@ -1843,7 +1819,7 @@ function convertCellToBlock$1(cell, index, idGenerator) {
1843
1819
  content: cell.content,
1844
1820
  id: idGenerator(),
1845
1821
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
1846
- sortingKey: createSortingKey(index),
1822
+ sortingKey: generateSortingKey(index),
1847
1823
  type: blockType
1848
1824
  };
1849
1825
  }
@@ -2033,7 +2009,7 @@ function convertQuartoDocumentToBlocks(document, options) {
2033
2009
  content: `# ${document.frontmatter.title}`,
2034
2010
  id: idGenerator(),
2035
2011
  metadata: {},
2036
- sortingKey: createSortingKey(blocks.length),
2012
+ sortingKey: generateSortingKey(blocks.length),
2037
2013
  type: "markdown"
2038
2014
  });
2039
2015
  for (const cell of document.cells) blocks.push(convertCellToBlock(cell, blocks.length, idGenerator));
@@ -2100,7 +2076,7 @@ async function readAndConvertQuartoFiles(inputFilePaths, options) {
2100
2076
  * Converts multiple Quarto (.qmd) files into a single Deepnote project file.
2101
2077
  */
2102
2078
  async function convertQuartoFilesToDeepnoteFile(inputFilePaths, options) {
2103
- const yamlContent = stringify(await readAndConvertQuartoFiles(inputFilePaths, { projectName: options.projectName }));
2079
+ const yamlContent = serializeDeepnoteFile(await readAndConvertQuartoFiles(inputFilePaths, { projectName: options.projectName }));
2104
2080
  const parentDir = dirname(options.outputPath);
2105
2081
  await fs.mkdir(parentDir, { recursive: true });
2106
2082
  await fs.writeFile(options.outputPath, yamlContent, "utf-8");
@@ -2121,7 +2097,7 @@ function convertCellToBlock(cell, index, idGenerator) {
2121
2097
  content: cell.content,
2122
2098
  id: idGenerator(),
2123
2099
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
2124
- sortingKey: createSortingKey(index),
2100
+ sortingKey: generateSortingKey(index),
2125
2101
  type: blockType
2126
2102
  };
2127
2103
  }
@@ -2146,15 +2122,15 @@ async function writeDeepnoteFile(options) {
2146
2122
  const parentDir = dirname(outputPath);
2147
2123
  await fs.mkdir(parentDir, { recursive: true });
2148
2124
  if (singleFile || !hasOutputs(file)) {
2149
- const yamlContent = stringify(file);
2125
+ const yamlContent = serializeDeepnoteFile(file);
2150
2126
  await fs.writeFile(outputPath, yamlContent, "utf-8");
2151
2127
  return { sourcePath: outputPath };
2152
2128
  }
2153
2129
  const { source, snapshot } = splitDeepnoteFile(file);
2154
2130
  const snapshotDir = getSnapshotDir(outputPath);
2155
2131
  const snapshotPath = resolve(snapshotDir, generateSnapshotFilename(slugifyProjectName(projectName) || "project", file.project.id));
2156
- const sourceYaml = stringify(source);
2157
- const snapshotYaml = stringify(snapshot);
2132
+ const sourceYaml = serializeDeepnoteFile(source);
2133
+ const snapshotYaml = serializeDeepnoteSnapshot(snapshot);
2158
2134
  await fs.mkdir(snapshotDir, { recursive: true });
2159
2135
  await Promise.all([fs.writeFile(outputPath, sourceYaml, "utf-8"), fs.writeFile(snapshotPath, snapshotYaml, "utf-8")]);
2160
2136
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnote/convert",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "cleye": "^2.0.0",
35
35
  "ora": "^9.0.0",
36
36
  "yaml": "^2.8.1",
37
- "@deepnote/blocks": "4.1.0"
37
+ "@deepnote/blocks": "4.3.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^22.0.0",