@deepnote/convert 3.1.1 → 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 +1 -1
- package/dist/bin.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-h056eQNO.cjs → src-BLBMaZtg.cjs} +5 -29
- package/dist/{src-BcZ91Lsd.js → src-BS7a6Oo0.js} +6 -30
- package/package.json +2 -2
package/dist/bin.cjs
CHANGED
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-
|
|
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";
|
package/dist/index.cjs
CHANGED
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-
|
|
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 };
|
|
@@ -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
|
|
@@ -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 ??
|
|
917
|
+
sortingKey: sortingKey ?? (0, __deepnote_blocks.generateSortingKey)(index),
|
|
942
918
|
type: blockType
|
|
943
919
|
}));
|
|
944
920
|
}
|
|
@@ -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:
|
|
1683
|
+
sortingKey: (0, __deepnote_blocks.generateSortingKey)(index),
|
|
1708
1684
|
type: blockType,
|
|
1709
1685
|
...outputs && outputs.length > 0 && (blockType === "code" || blockType === "sql") ? { outputs } : {}
|
|
1710
1686
|
};
|
|
@@ -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:
|
|
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:
|
|
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));
|
|
@@ -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:
|
|
2128
|
+
sortingKey: (0, __deepnote_blocks.generateSortingKey)(index),
|
|
2153
2129
|
type: blockType
|
|
2154
2130
|
};
|
|
2155
2131
|
}
|
|
@@ -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,
|
|
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
|
|
@@ -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 ??
|
|
889
|
+
sortingKey: sortingKey ?? generateSortingKey(index),
|
|
914
890
|
type: blockType
|
|
915
891
|
}));
|
|
916
892
|
}
|
|
@@ -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:
|
|
1655
|
+
sortingKey: generateSortingKey(index),
|
|
1680
1656
|
type: blockType,
|
|
1681
1657
|
...outputs && outputs.length > 0 && (blockType === "code" || blockType === "sql") ? { outputs } : {}
|
|
1682
1658
|
};
|
|
@@ -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:
|
|
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:
|
|
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));
|
|
@@ -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:
|
|
2100
|
+
sortingKey: generateSortingKey(index),
|
|
2125
2101
|
type: blockType
|
|
2126
2102
|
};
|
|
2127
2103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepnote/convert",
|
|
3
|
-
"version": "3.
|
|
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.
|
|
37
|
+
"@deepnote/blocks": "4.3.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^22.0.0",
|