@deepnote/blocks 4.2.0 → 4.3.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/index.cjs +23 -2
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +23 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -655,17 +655,37 @@ const yamlOptions = {
|
|
|
655
655
|
defaultStringType: "PLAIN",
|
|
656
656
|
defaultKeyType: "PLAIN"
|
|
657
657
|
};
|
|
658
|
+
function generateSortingKey(index) {
|
|
659
|
+
return String(index).padStart(6, "0");
|
|
660
|
+
}
|
|
661
|
+
function normalizeSortingKeys(data) {
|
|
662
|
+
return {
|
|
663
|
+
...data,
|
|
664
|
+
project: {
|
|
665
|
+
...data.project,
|
|
666
|
+
notebooks: data.project.notebooks.map((notebook) => ({
|
|
667
|
+
...notebook,
|
|
668
|
+
blocks: notebook.blocks.map((block, index) => ({
|
|
669
|
+
...block,
|
|
670
|
+
sortingKey: generateSortingKey(index)
|
|
671
|
+
}))
|
|
672
|
+
}))
|
|
673
|
+
}
|
|
674
|
+
};
|
|
675
|
+
}
|
|
658
676
|
/**
|
|
659
677
|
* Serialize a DeepnoteFile to a YAML string.
|
|
660
678
|
*/
|
|
661
679
|
function serializeDeepnoteFile(file) {
|
|
662
|
-
|
|
680
|
+
const withNormalizedSortingKeys = normalizeSortingKeys(file);
|
|
681
|
+
return (0, yaml.stringify)(deepnoteFileSchema.parse(withNormalizedSortingKeys), yamlOptions);
|
|
663
682
|
}
|
|
664
683
|
/**
|
|
665
684
|
* Serialize a DeepnoteSnapshot to a YAML string.
|
|
666
685
|
*/
|
|
667
686
|
function serializeDeepnoteSnapshot(snapshot) {
|
|
668
|
-
|
|
687
|
+
const withNormalizedSortingKeys = normalizeSortingKeys(snapshot);
|
|
688
|
+
return (0, yaml.stringify)(deepnoteSnapshotSchema.parse(withNormalizedSortingKeys), yamlOptions);
|
|
669
689
|
}
|
|
670
690
|
|
|
671
691
|
//#endregion
|
|
@@ -1207,6 +1227,7 @@ exports.environmentSchema = environmentSchema;
|
|
|
1207
1227
|
exports.executionErrorSchema = executionErrorSchema;
|
|
1208
1228
|
exports.executionSchema = executionSchema;
|
|
1209
1229
|
exports.executionSummarySchema = executionSummarySchema;
|
|
1230
|
+
exports.generateSortingKey = generateSortingKey;
|
|
1210
1231
|
exports.getSqlEnvVarName = getSqlEnvVarName;
|
|
1211
1232
|
exports.isExecutableBlock = isExecutableBlock;
|
|
1212
1233
|
exports.isExecutableBlockType = isExecutableBlockType;
|
package/dist/index.d.cts
CHANGED
|
@@ -23570,6 +23570,7 @@ declare function decodeUtf8NoBom(bytes: Uint8Array): string;
|
|
|
23570
23570
|
declare function parseYaml(yamlContent: string): unknown;
|
|
23571
23571
|
//#endregion
|
|
23572
23572
|
//#region src/deepnote-file/serialize-deepnote-file.d.ts
|
|
23573
|
+
declare function generateSortingKey(index: number): string;
|
|
23573
23574
|
/**
|
|
23574
23575
|
* Serialize a DeepnoteFile to a YAML string.
|
|
23575
23576
|
*/
|
|
@@ -23595,4 +23596,4 @@ interface ButtonExecutionContext {
|
|
|
23595
23596
|
//#region src/python-code.d.ts
|
|
23596
23597
|
declare function createPythonCode(block: DeepnoteBlock, executionContext?: ButtonExecutionContext): string;
|
|
23597
23598
|
//#endregion
|
|
23598
|
-
export { type DeepnoteBlock, DeepnoteError, type DeepnoteFile, type DeepnoteSnapshot, EncodingError, type Environment, type ExecutableBlock, type Execution, type ExecutionError, type ExecutionSummary, INPUT_BLOCK_TYPES, InvalidValueError, ParseError, ProhibitedYamlFeatureError, SchemaValidationError, type SnapshotHashInput, type TableState, UnsupportedBlockTypeError, YamlParseError, convertToEnvironmentVariableName, createMarkdown, createPythonCode, decodeUtf8NoBom, deepnoteBlockSchema, deepnoteFileSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionErrorSchema, executionSchema, executionSummarySchema, getSqlEnvVarName, isExecutableBlock, isExecutableBlockType, parseYaml, serializeDeepnoteFile, serializeDeepnoteSnapshot, stripMarkdown };
|
|
23599
|
+
export { type DeepnoteBlock, DeepnoteError, type DeepnoteFile, type DeepnoteSnapshot, EncodingError, type Environment, type ExecutableBlock, type Execution, type ExecutionError, type ExecutionSummary, INPUT_BLOCK_TYPES, InvalidValueError, ParseError, ProhibitedYamlFeatureError, SchemaValidationError, type SnapshotHashInput, type TableState, UnsupportedBlockTypeError, YamlParseError, convertToEnvironmentVariableName, createMarkdown, createPythonCode, decodeUtf8NoBom, deepnoteBlockSchema, deepnoteFileSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionErrorSchema, executionSchema, executionSummarySchema, generateSortingKey, getSqlEnvVarName, isExecutableBlock, isExecutableBlockType, parseYaml, serializeDeepnoteFile, serializeDeepnoteSnapshot, stripMarkdown };
|
package/dist/index.d.ts
CHANGED
|
@@ -23570,6 +23570,7 @@ declare function decodeUtf8NoBom(bytes: Uint8Array): string;
|
|
|
23570
23570
|
declare function parseYaml(yamlContent: string): unknown;
|
|
23571
23571
|
//#endregion
|
|
23572
23572
|
//#region src/deepnote-file/serialize-deepnote-file.d.ts
|
|
23573
|
+
declare function generateSortingKey(index: number): string;
|
|
23573
23574
|
/**
|
|
23574
23575
|
* Serialize a DeepnoteFile to a YAML string.
|
|
23575
23576
|
*/
|
|
@@ -23595,4 +23596,4 @@ interface ButtonExecutionContext {
|
|
|
23595
23596
|
//#region src/python-code.d.ts
|
|
23596
23597
|
declare function createPythonCode(block: DeepnoteBlock, executionContext?: ButtonExecutionContext): string;
|
|
23597
23598
|
//#endregion
|
|
23598
|
-
export { type DeepnoteBlock, DeepnoteError, type DeepnoteFile, type DeepnoteSnapshot, EncodingError, type Environment, type ExecutableBlock, type Execution, type ExecutionError, type ExecutionSummary, INPUT_BLOCK_TYPES, InvalidValueError, ParseError, ProhibitedYamlFeatureError, SchemaValidationError, type SnapshotHashInput, type TableState, UnsupportedBlockTypeError, YamlParseError, convertToEnvironmentVariableName, createMarkdown, createPythonCode, decodeUtf8NoBom, deepnoteBlockSchema, deepnoteFileSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionErrorSchema, executionSchema, executionSummarySchema, getSqlEnvVarName, isExecutableBlock, isExecutableBlockType, parseYaml, serializeDeepnoteFile, serializeDeepnoteSnapshot, stripMarkdown };
|
|
23599
|
+
export { type DeepnoteBlock, DeepnoteError, type DeepnoteFile, type DeepnoteSnapshot, EncodingError, type Environment, type ExecutableBlock, type Execution, type ExecutionError, type ExecutionSummary, INPUT_BLOCK_TYPES, InvalidValueError, ParseError, ProhibitedYamlFeatureError, SchemaValidationError, type SnapshotHashInput, type TableState, UnsupportedBlockTypeError, YamlParseError, convertToEnvironmentVariableName, createMarkdown, createPythonCode, decodeUtf8NoBom, deepnoteBlockSchema, deepnoteFileSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionErrorSchema, executionSchema, executionSummarySchema, generateSortingKey, getSqlEnvVarName, isExecutableBlock, isExecutableBlockType, parseYaml, serializeDeepnoteFile, serializeDeepnoteSnapshot, stripMarkdown };
|
package/dist/index.js
CHANGED
|
@@ -629,17 +629,37 @@ const yamlOptions = {
|
|
|
629
629
|
defaultStringType: "PLAIN",
|
|
630
630
|
defaultKeyType: "PLAIN"
|
|
631
631
|
};
|
|
632
|
+
function generateSortingKey(index) {
|
|
633
|
+
return String(index).padStart(6, "0");
|
|
634
|
+
}
|
|
635
|
+
function normalizeSortingKeys(data) {
|
|
636
|
+
return {
|
|
637
|
+
...data,
|
|
638
|
+
project: {
|
|
639
|
+
...data.project,
|
|
640
|
+
notebooks: data.project.notebooks.map((notebook) => ({
|
|
641
|
+
...notebook,
|
|
642
|
+
blocks: notebook.blocks.map((block, index) => ({
|
|
643
|
+
...block,
|
|
644
|
+
sortingKey: generateSortingKey(index)
|
|
645
|
+
}))
|
|
646
|
+
}))
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
}
|
|
632
650
|
/**
|
|
633
651
|
* Serialize a DeepnoteFile to a YAML string.
|
|
634
652
|
*/
|
|
635
653
|
function serializeDeepnoteFile(file) {
|
|
636
|
-
|
|
654
|
+
const withNormalizedSortingKeys = normalizeSortingKeys(file);
|
|
655
|
+
return stringify(deepnoteFileSchema.parse(withNormalizedSortingKeys), yamlOptions);
|
|
637
656
|
}
|
|
638
657
|
/**
|
|
639
658
|
* Serialize a DeepnoteSnapshot to a YAML string.
|
|
640
659
|
*/
|
|
641
660
|
function serializeDeepnoteSnapshot(snapshot) {
|
|
642
|
-
|
|
661
|
+
const withNormalizedSortingKeys = normalizeSortingKeys(snapshot);
|
|
662
|
+
return stringify(deepnoteSnapshotSchema.parse(withNormalizedSortingKeys), yamlOptions);
|
|
643
663
|
}
|
|
644
664
|
|
|
645
665
|
//#endregion
|
|
@@ -1160,4 +1180,4 @@ function createPythonCode(block, executionContext) {
|
|
|
1160
1180
|
}
|
|
1161
1181
|
|
|
1162
1182
|
//#endregion
|
|
1163
|
-
export { DeepnoteError, EncodingError, INPUT_BLOCK_TYPES, InvalidValueError, ParseError, ProhibitedYamlFeatureError, SchemaValidationError, UnsupportedBlockTypeError, YamlParseError, convertToEnvironmentVariableName, createMarkdown, createPythonCode, decodeUtf8NoBom, deepnoteBlockSchema, deepnoteFileSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionErrorSchema, executionSchema, executionSummarySchema, getSqlEnvVarName, isExecutableBlock, isExecutableBlockType, parseYaml, serializeDeepnoteFile, serializeDeepnoteSnapshot, stripMarkdown };
|
|
1183
|
+
export { DeepnoteError, EncodingError, INPUT_BLOCK_TYPES, InvalidValueError, ParseError, ProhibitedYamlFeatureError, SchemaValidationError, UnsupportedBlockTypeError, YamlParseError, convertToEnvironmentVariableName, createMarkdown, createPythonCode, decodeUtf8NoBom, deepnoteBlockSchema, deepnoteFileSchema, deepnoteSnapshotSchema, deserializeDeepnoteFile, environmentSchema, executionErrorSchema, executionSchema, executionSummarySchema, generateSortingKey, getSqlEnvVarName, isExecutableBlock, isExecutableBlockType, parseYaml, serializeDeepnoteFile, serializeDeepnoteSnapshot, stripMarkdown };
|