@deepnote/blocks 4.1.0 → 4.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/index.cjs +27 -3
- package/dist/index.d.cts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +27 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -135,7 +135,7 @@ function getSqlEnvVarName(integrationId) {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
//#endregion
|
|
138
|
-
//#region src/
|
|
138
|
+
//#region src/deepnote-file/deepnote-file-schema.ts
|
|
139
139
|
/** Preprocesses any content value to empty string for blocks that don't use content */
|
|
140
140
|
const emptyContent = () => zod.z.preprocess(() => "", zod.z.literal("").optional());
|
|
141
141
|
const baseBlockMetadataSchema = zod.z.object({
|
|
@@ -540,7 +540,7 @@ const deepnoteSnapshotSchema = deepnoteFileSchema.extend({
|
|
|
540
540
|
});
|
|
541
541
|
|
|
542
542
|
//#endregion
|
|
543
|
-
//#region src/
|
|
543
|
+
//#region src/deepnote-file/parse-yaml.ts
|
|
544
544
|
/**
|
|
545
545
|
* Validates UTF-8 encoding from raw bytes before decoding to string.
|
|
546
546
|
* This is the proper way to validate UTF-8 - check BEFORE decoding.
|
|
@@ -630,7 +630,7 @@ function parseYaml(yamlContent) {
|
|
|
630
630
|
}
|
|
631
631
|
|
|
632
632
|
//#endregion
|
|
633
|
-
//#region src/
|
|
633
|
+
//#region src/deepnote-file/deserialize-deepnote-file.ts
|
|
634
634
|
/**
|
|
635
635
|
* Deserialize a YAML string into a DeepnoteFile object.
|
|
636
636
|
*/
|
|
@@ -646,6 +646,28 @@ function deserializeDeepnoteFile(yamlContent) {
|
|
|
646
646
|
return result.data;
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region src/deepnote-file/serialize-deepnote-file.ts
|
|
651
|
+
const yamlOptions = {
|
|
652
|
+
indent: 2,
|
|
653
|
+
lineWidth: 120,
|
|
654
|
+
blockQuote: "folded",
|
|
655
|
+
defaultStringType: "PLAIN",
|
|
656
|
+
defaultKeyType: "PLAIN"
|
|
657
|
+
};
|
|
658
|
+
/**
|
|
659
|
+
* Serialize a DeepnoteFile to a YAML string.
|
|
660
|
+
*/
|
|
661
|
+
function serializeDeepnoteFile(file) {
|
|
662
|
+
return (0, yaml.stringify)(deepnoteFileSchema.parse(file), yamlOptions);
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Serialize a DeepnoteSnapshot to a YAML string.
|
|
666
|
+
*/
|
|
667
|
+
function serializeDeepnoteSnapshot(snapshot) {
|
|
668
|
+
return (0, yaml.stringify)(deepnoteSnapshotSchema.parse(snapshot), yamlOptions);
|
|
669
|
+
}
|
|
670
|
+
|
|
649
671
|
//#endregion
|
|
650
672
|
//#region src/blocks/image-blocks.ts
|
|
651
673
|
function escapeHtmlAttribute(value) {
|
|
@@ -1189,4 +1211,6 @@ exports.getSqlEnvVarName = getSqlEnvVarName;
|
|
|
1189
1211
|
exports.isExecutableBlock = isExecutableBlock;
|
|
1190
1212
|
exports.isExecutableBlockType = isExecutableBlockType;
|
|
1191
1213
|
exports.parseYaml = parseYaml;
|
|
1214
|
+
exports.serializeDeepnoteFile = serializeDeepnoteFile;
|
|
1215
|
+
exports.serializeDeepnoteSnapshot = serializeDeepnoteSnapshot;
|
|
1192
1216
|
exports.stripMarkdown = stripMarkdown;
|
package/dist/index.d.cts
CHANGED
|
@@ -52,7 +52,7 @@ declare class InvalidValueError extends DeepnoteError {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
|
-
//#region src/
|
|
55
|
+
//#region src/deepnote-file/deepnote-file-schema.d.ts
|
|
56
56
|
|
|
57
57
|
declare const codeBlockSchema: z.ZodObject<{
|
|
58
58
|
type: z.ZodLiteral<"code">;
|
|
@@ -23535,13 +23535,13 @@ interface TableState {
|
|
|
23535
23535
|
wrappedTextColumnIds?: string[];
|
|
23536
23536
|
}
|
|
23537
23537
|
//#endregion
|
|
23538
|
-
//#region src/
|
|
23538
|
+
//#region src/deepnote-file/deserialize-deepnote-file.d.ts
|
|
23539
23539
|
/**
|
|
23540
23540
|
* Deserialize a YAML string into a DeepnoteFile object.
|
|
23541
23541
|
*/
|
|
23542
23542
|
declare function deserializeDeepnoteFile(yamlContent: string): DeepnoteFile;
|
|
23543
23543
|
//#endregion
|
|
23544
|
-
//#region src/
|
|
23544
|
+
//#region src/deepnote-file/parse-yaml.d.ts
|
|
23545
23545
|
/**
|
|
23546
23546
|
* Validates UTF-8 encoding from raw bytes before decoding to string.
|
|
23547
23547
|
* This is the proper way to validate UTF-8 - check BEFORE decoding.
|
|
@@ -23569,6 +23569,16 @@ declare function decodeUtf8NoBom(bytes: Uint8Array): string;
|
|
|
23569
23569
|
*/
|
|
23570
23570
|
declare function parseYaml(yamlContent: string): unknown;
|
|
23571
23571
|
//#endregion
|
|
23572
|
+
//#region src/deepnote-file/serialize-deepnote-file.d.ts
|
|
23573
|
+
/**
|
|
23574
|
+
* Serialize a DeepnoteFile to a YAML string.
|
|
23575
|
+
*/
|
|
23576
|
+
declare function serializeDeepnoteFile(file: DeepnoteFile): string;
|
|
23577
|
+
/**
|
|
23578
|
+
* Serialize a DeepnoteSnapshot to a YAML string.
|
|
23579
|
+
*/
|
|
23580
|
+
declare function serializeDeepnoteSnapshot(snapshot: DeepnoteSnapshot): string;
|
|
23581
|
+
//#endregion
|
|
23572
23582
|
//#region src/markdown.d.ts
|
|
23573
23583
|
declare function createMarkdown(block: DeepnoteBlock): string;
|
|
23574
23584
|
declare function stripMarkdown(block: DeepnoteBlock): string;
|
|
@@ -23585,4 +23595,4 @@ interface ButtonExecutionContext {
|
|
|
23585
23595
|
//#region src/python-code.d.ts
|
|
23586
23596
|
declare function createPythonCode(block: DeepnoteBlock, executionContext?: ButtonExecutionContext): string;
|
|
23587
23597
|
//#endregion
|
|
23588
|
-
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, stripMarkdown };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ declare class InvalidValueError extends DeepnoteError {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
|
-
//#region src/
|
|
55
|
+
//#region src/deepnote-file/deepnote-file-schema.d.ts
|
|
56
56
|
|
|
57
57
|
declare const codeBlockSchema: z.ZodObject<{
|
|
58
58
|
type: z.ZodLiteral<"code">;
|
|
@@ -23535,13 +23535,13 @@ interface TableState {
|
|
|
23535
23535
|
wrappedTextColumnIds?: string[];
|
|
23536
23536
|
}
|
|
23537
23537
|
//#endregion
|
|
23538
|
-
//#region src/
|
|
23538
|
+
//#region src/deepnote-file/deserialize-deepnote-file.d.ts
|
|
23539
23539
|
/**
|
|
23540
23540
|
* Deserialize a YAML string into a DeepnoteFile object.
|
|
23541
23541
|
*/
|
|
23542
23542
|
declare function deserializeDeepnoteFile(yamlContent: string): DeepnoteFile;
|
|
23543
23543
|
//#endregion
|
|
23544
|
-
//#region src/
|
|
23544
|
+
//#region src/deepnote-file/parse-yaml.d.ts
|
|
23545
23545
|
/**
|
|
23546
23546
|
* Validates UTF-8 encoding from raw bytes before decoding to string.
|
|
23547
23547
|
* This is the proper way to validate UTF-8 - check BEFORE decoding.
|
|
@@ -23569,6 +23569,16 @@ declare function decodeUtf8NoBom(bytes: Uint8Array): string;
|
|
|
23569
23569
|
*/
|
|
23570
23570
|
declare function parseYaml(yamlContent: string): unknown;
|
|
23571
23571
|
//#endregion
|
|
23572
|
+
//#region src/deepnote-file/serialize-deepnote-file.d.ts
|
|
23573
|
+
/**
|
|
23574
|
+
* Serialize a DeepnoteFile to a YAML string.
|
|
23575
|
+
*/
|
|
23576
|
+
declare function serializeDeepnoteFile(file: DeepnoteFile): string;
|
|
23577
|
+
/**
|
|
23578
|
+
* Serialize a DeepnoteSnapshot to a YAML string.
|
|
23579
|
+
*/
|
|
23580
|
+
declare function serializeDeepnoteSnapshot(snapshot: DeepnoteSnapshot): string;
|
|
23581
|
+
//#endregion
|
|
23572
23582
|
//#region src/markdown.d.ts
|
|
23573
23583
|
declare function createMarkdown(block: DeepnoteBlock): string;
|
|
23574
23584
|
declare function stripMarkdown(block: DeepnoteBlock): string;
|
|
@@ -23585,4 +23595,4 @@ interface ButtonExecutionContext {
|
|
|
23585
23595
|
//#region src/python-code.d.ts
|
|
23586
23596
|
declare function createPythonCode(block: DeepnoteBlock, executionContext?: ButtonExecutionContext): string;
|
|
23587
23597
|
//#endregion
|
|
23588
|
-
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, stripMarkdown };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { parseDocument } from "yaml";
|
|
2
|
+
import { parseDocument, stringify } from "yaml";
|
|
3
3
|
import { dedent } from "ts-dedent";
|
|
4
4
|
|
|
5
5
|
//#region src/errors.ts
|
|
@@ -109,7 +109,7 @@ function getSqlEnvVarName(integrationId) {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
//#endregion
|
|
112
|
-
//#region src/
|
|
112
|
+
//#region src/deepnote-file/deepnote-file-schema.ts
|
|
113
113
|
/** Preprocesses any content value to empty string for blocks that don't use content */
|
|
114
114
|
const emptyContent = () => z.preprocess(() => "", z.literal("").optional());
|
|
115
115
|
const baseBlockMetadataSchema = z.object({
|
|
@@ -514,7 +514,7 @@ const deepnoteSnapshotSchema = deepnoteFileSchema.extend({
|
|
|
514
514
|
});
|
|
515
515
|
|
|
516
516
|
//#endregion
|
|
517
|
-
//#region src/
|
|
517
|
+
//#region src/deepnote-file/parse-yaml.ts
|
|
518
518
|
/**
|
|
519
519
|
* Validates UTF-8 encoding from raw bytes before decoding to string.
|
|
520
520
|
* This is the proper way to validate UTF-8 - check BEFORE decoding.
|
|
@@ -604,7 +604,7 @@ function parseYaml(yamlContent) {
|
|
|
604
604
|
}
|
|
605
605
|
|
|
606
606
|
//#endregion
|
|
607
|
-
//#region src/
|
|
607
|
+
//#region src/deepnote-file/deserialize-deepnote-file.ts
|
|
608
608
|
/**
|
|
609
609
|
* Deserialize a YAML string into a DeepnoteFile object.
|
|
610
610
|
*/
|
|
@@ -620,6 +620,28 @@ function deserializeDeepnoteFile(yamlContent) {
|
|
|
620
620
|
return result.data;
|
|
621
621
|
}
|
|
622
622
|
|
|
623
|
+
//#endregion
|
|
624
|
+
//#region src/deepnote-file/serialize-deepnote-file.ts
|
|
625
|
+
const yamlOptions = {
|
|
626
|
+
indent: 2,
|
|
627
|
+
lineWidth: 120,
|
|
628
|
+
blockQuote: "folded",
|
|
629
|
+
defaultStringType: "PLAIN",
|
|
630
|
+
defaultKeyType: "PLAIN"
|
|
631
|
+
};
|
|
632
|
+
/**
|
|
633
|
+
* Serialize a DeepnoteFile to a YAML string.
|
|
634
|
+
*/
|
|
635
|
+
function serializeDeepnoteFile(file) {
|
|
636
|
+
return stringify(deepnoteFileSchema.parse(file), yamlOptions);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Serialize a DeepnoteSnapshot to a YAML string.
|
|
640
|
+
*/
|
|
641
|
+
function serializeDeepnoteSnapshot(snapshot) {
|
|
642
|
+
return stringify(deepnoteSnapshotSchema.parse(snapshot), yamlOptions);
|
|
643
|
+
}
|
|
644
|
+
|
|
623
645
|
//#endregion
|
|
624
646
|
//#region src/blocks/image-blocks.ts
|
|
625
647
|
function escapeHtmlAttribute(value) {
|
|
@@ -1138,4 +1160,4 @@ function createPythonCode(block, executionContext) {
|
|
|
1138
1160
|
}
|
|
1139
1161
|
|
|
1140
1162
|
//#endregion
|
|
1141
|
-
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, stripMarkdown };
|
|
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 };
|