@deepnote/convert 3.1.1 → 3.2.1

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-h056eQNO.cjs');
2
+ const require_src = require('./src-CtWT7fu0.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 { 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-BcZ91Lsd.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-DB1r0z58.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";
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_src = require('./src-h056eQNO.cjs');
1
+ const require_src = require('./src-CtWT7fu0.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-BcZ91Lsd.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-DB1r0z58.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 };
@@ -34,30 +34,6 @@ 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
@@ -71,6 +47,7 @@ function sanitizeFileName(name) {
71
47
  * Unknown types default to markdown (less lossy).
72
48
  */
73
49
  const CODE_BLOCK_TYPES = [
50
+ "agent",
74
51
  "big-number",
75
52
  "button",
76
53
  "code",
@@ -938,7 +915,7 @@ function convertCellToBlock$3(cell, index, idGenerator) {
938
915
  id: cellId ?? idGenerator(),
939
916
  metadata: originalMetadata,
940
917
  ...hasOutputs$1 ? { outputs: cell.outputs } : {},
941
- sortingKey: sortingKey ?? createSortingKey(index),
918
+ sortingKey: sortingKey ?? (0, __deepnote_blocks.generateSortingKey)(index),
942
919
  type: blockType
943
920
  }));
944
921
  }
@@ -1704,7 +1681,7 @@ function convertCellToBlock$2(cell, index, idGenerator, outputs) {
1704
1681
  content: cell.content,
1705
1682
  id: idGenerator(),
1706
1683
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
1707
- sortingKey: createSortingKey(index),
1684
+ sortingKey: (0, __deepnote_blocks.generateSortingKey)(index),
1708
1685
  type: blockType,
1709
1686
  ...outputs && outputs.length > 0 && (blockType === "code" || blockType === "sql") ? { outputs } : {}
1710
1687
  };
@@ -1871,7 +1848,7 @@ function convertCellToBlock$1(cell, index, idGenerator) {
1871
1848
  content: cell.content,
1872
1849
  id: idGenerator(),
1873
1850
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
1874
- sortingKey: createSortingKey(index),
1851
+ sortingKey: (0, __deepnote_blocks.generateSortingKey)(index),
1875
1852
  type: blockType
1876
1853
  };
1877
1854
  }
@@ -2061,7 +2038,7 @@ function convertQuartoDocumentToBlocks(document, options) {
2061
2038
  content: `# ${document.frontmatter.title}`,
2062
2039
  id: idGenerator(),
2063
2040
  metadata: {},
2064
- sortingKey: createSortingKey(blocks.length),
2041
+ sortingKey: (0, __deepnote_blocks.generateSortingKey)(blocks.length),
2065
2042
  type: "markdown"
2066
2043
  });
2067
2044
  for (const cell of document.cells) blocks.push(convertCellToBlock(cell, blocks.length, idGenerator));
@@ -2149,7 +2126,7 @@ function convertCellToBlock(cell, index, idGenerator) {
2149
2126
  content: cell.content,
2150
2127
  id: idGenerator(),
2151
2128
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
2152
- sortingKey: createSortingKey(index),
2129
+ sortingKey: (0, __deepnote_blocks.generateSortingKey)(index),
2153
2130
  type: blockType
2154
2131
  };
2155
2132
  }
@@ -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, serializeDeepnoteFile, serializeDeepnoteSnapshot } from "@deepnote/blocks";
3
+ import { DeepnoteError, ParseError, createMarkdown, createPythonCode, deepnoteBlockSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionSchema, generateSortingKey, isExecutableBlockType, serializeDeepnoteFile, serializeDeepnoteSnapshot } from "@deepnote/blocks";
4
4
  import { createHash, randomUUID } from "node:crypto";
5
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
@@ -43,6 +19,7 @@ function sanitizeFileName(name) {
43
19
  * Unknown types default to markdown (less lossy).
44
20
  */
45
21
  const CODE_BLOCK_TYPES = [
22
+ "agent",
46
23
  "big-number",
47
24
  "button",
48
25
  "code",
@@ -910,7 +887,7 @@ function convertCellToBlock$3(cell, index, idGenerator) {
910
887
  id: cellId ?? idGenerator(),
911
888
  metadata: originalMetadata,
912
889
  ...hasOutputs$1 ? { outputs: cell.outputs } : {},
913
- sortingKey: sortingKey ?? createSortingKey(index),
890
+ sortingKey: sortingKey ?? generateSortingKey(index),
914
891
  type: blockType
915
892
  }));
916
893
  }
@@ -1676,7 +1653,7 @@ function convertCellToBlock$2(cell, index, idGenerator, outputs) {
1676
1653
  content: cell.content,
1677
1654
  id: idGenerator(),
1678
1655
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
1679
- sortingKey: createSortingKey(index),
1656
+ sortingKey: generateSortingKey(index),
1680
1657
  type: blockType,
1681
1658
  ...outputs && outputs.length > 0 && (blockType === "code" || blockType === "sql") ? { outputs } : {}
1682
1659
  };
@@ -1843,7 +1820,7 @@ function convertCellToBlock$1(cell, index, idGenerator) {
1843
1820
  content: cell.content,
1844
1821
  id: idGenerator(),
1845
1822
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
1846
- sortingKey: createSortingKey(index),
1823
+ sortingKey: generateSortingKey(index),
1847
1824
  type: blockType
1848
1825
  };
1849
1826
  }
@@ -2033,7 +2010,7 @@ function convertQuartoDocumentToBlocks(document, options) {
2033
2010
  content: `# ${document.frontmatter.title}`,
2034
2011
  id: idGenerator(),
2035
2012
  metadata: {},
2036
- sortingKey: createSortingKey(blocks.length),
2013
+ sortingKey: generateSortingKey(blocks.length),
2037
2014
  type: "markdown"
2038
2015
  });
2039
2016
  for (const cell of document.cells) blocks.push(convertCellToBlock(cell, blocks.length, idGenerator));
@@ -2121,7 +2098,7 @@ function convertCellToBlock(cell, index, idGenerator) {
2121
2098
  content: cell.content,
2122
2099
  id: idGenerator(),
2123
2100
  metadata: Object.keys(metadata).length > 0 ? metadata : {},
2124
- sortingKey: createSortingKey(index),
2101
+ sortingKey: generateSortingKey(index),
2125
2102
  type: blockType
2126
2103
  };
2127
2104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepnote/convert",
3
- "version": "3.1.1",
3
+ "version": "3.2.1",
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.2.0"
37
+ "@deepnote/blocks": "4.4.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^22.0.0",