Skip to content

Commit ce6559f

Browse files
committed
Use types from @deepnote/blocks.
1 parent f0eb561 commit ce6559f

File tree

7 files changed

+97
-74
lines changed

7 files changed

+97
-74
lines changed

package-lock.json

Lines changed: 44 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@
20992099
},
21002100
"dependencies": {
21012101
"@c4312/evt": "^0.1.1",
2102-
"@deepnote/blocks": "^1.0.0",
2102+
"@deepnote/blocks": "^1.1.0",
21032103
"@enonic/fnv-plus": "^1.3.0",
21042104
"@jupyter-widgets/base": "^6.0.8",
21052105
"@jupyter-widgets/controls": "^5.0.9",

src/notebooks/deepnote/deepnoteSerializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IDeepnoteNotebookManager } from '../types';
66
import type { DeepnoteProject } from './deepnoteTypes';
77
import { DeepnoteDataConverter } from './deepnoteDataConverter';
88

9-
export { DeepnoteProject, DeepnoteNotebook, DeepnoteBlock, DeepnoteOutput } from './deepnoteTypes';
9+
export { DeepnoteProject, DeepnoteNotebook, DeepnoteOutput } from './deepnoteTypes';
1010

1111
/**
1212
* Serializer for converting between Deepnote YAML files and VS Code notebook format.

src/notebooks/deepnote/deepnoteSerializer.unit.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ suite('DeepnoteNotebookSerializer', () => {
3030
type: 'code'
3131
}
3232
],
33-
executionMode: 'python',
33+
executionMode: 'block',
3434
isModule: false
3535
},
3636
{
@@ -45,7 +45,7 @@ suite('DeepnoteNotebookSerializer', () => {
4545
type: 'markdown'
4646
}
4747
],
48-
executionMode: 'python',
48+
executionMode: 'block',
4949
isModule: false
5050
}
5151
],
@@ -80,7 +80,7 @@ project:
8080
content: 'print("hello")'
8181
sortingKey: 'a0'
8282
type: 'code'
83-
executionMode: 'python'
83+
executionMode: 'block'
8484
isModule: false
8585
settings: {}
8686
`;
@@ -278,7 +278,7 @@ project:
278278
test('should handle notebook metadata', () => {
279279
const notebook = mockProject.project.notebooks[0];
280280

281-
assert.strictEqual(notebook.executionMode, 'python');
281+
assert.strictEqual(notebook.executionMode, 'block');
282282
assert.strictEqual(notebook.isModule, false);
283283
assert.isDefined(notebook.blocks);
284284
assert.isArray(notebook.blocks);

src/notebooks/deepnote/deepnoteTreeDataProvider.unit.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ suite('DeepnoteTreeDataProvider', () => {
2828
type: 'code'
2929
}
3030
],
31-
executionMode: 'python',
31+
executionMode: 'block',
3232
isModule: false
3333
},
3434
{
@@ -43,7 +43,7 @@ suite('DeepnoteTreeDataProvider', () => {
4343
type: 'markdown'
4444
}
4545
],
46-
executionMode: 'python',
46+
executionMode: 'block',
4747
isModule: false
4848
}
4949
],
@@ -111,7 +111,7 @@ suite('DeepnoteTreeDataProvider', () => {
111111
id: 'notebook-1',
112112
name: 'Test Notebook',
113113
blocks: [],
114-
executionMode: 'python',
114+
executionMode: 'block',
115115
isModule: false
116116
},
117117
0 // TreeItemCollapsibleState.None

src/notebooks/deepnote/deepnoteTreeItem.unit.test.ts

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ suite('DeepnoteTreeItem', () => {
1818
id: 'notebook-1',
1919
name: 'First Notebook',
2020
blocks: [],
21-
executionMode: 'python',
21+
executionMode: 'block',
2222
isModule: false
2323
}
2424
],
@@ -31,7 +31,7 @@ suite('DeepnoteTreeItem', () => {
3131
id: 'notebook-456',
3232
name: 'Analysis Notebook',
3333
blocks: [{ blockGroup: 'group-123', id: 'block-1', content: 'print("hello")', sortingKey: 'a0', type: 'code' }],
34-
executionMode: 'python',
34+
executionMode: 'block',
3535
isModule: false
3636
};
3737

@@ -124,14 +124,32 @@ suite('DeepnoteTreeItem', () => {
124124
});
125125

126126
test('should handle project with multiple notebooks', () => {
127-
const projectWithMultipleNotebooks = {
127+
const projectWithMultipleNotebooks: DeepnoteProject = {
128128
...mockProject,
129129
project: {
130130
...mockProject.project,
131131
notebooks: [
132-
{ id: 'notebook-1', name: 'First', blocks: [], executionMode: 'python', isModule: false },
133-
{ id: 'notebook-2', name: 'Second', blocks: [], executionMode: 'python', isModule: false },
134-
{ id: 'notebook-3', name: 'Third', blocks: [], executionMode: 'python', isModule: false }
132+
{
133+
id: 'notebook-1',
134+
name: 'First',
135+
blocks: [],
136+
executionMode: 'block' as const,
137+
isModule: false
138+
},
139+
{
140+
id: 'notebook-2',
141+
name: 'Second',
142+
blocks: [],
143+
executionMode: 'block' as const,
144+
isModule: false
145+
},
146+
{
147+
id: 'notebook-3',
148+
name: 'Third',
149+
blocks: [],
150+
executionMode: 'block' as const,
151+
isModule: false
152+
}
135153
]
136154
}
137155
};
@@ -219,7 +237,7 @@ suite('DeepnoteTreeItem', () => {
219237
assert.strictEqual(item.type, DeepnoteTreeItemType.Notebook);
220238
assert.strictEqual(item.collapsibleState, TreeItemCollapsibleState.None);
221239
assert.strictEqual(item.contextValue, 'notebook');
222-
assert.strictEqual(item.tooltip, 'Notebook: Analysis Notebook\nExecution Mode: python');
240+
assert.strictEqual(item.tooltip, 'Notebook: Analysis Notebook\nExecution Mode: block');
223241
assert.strictEqual(item.description, '1 cell');
224242

225243
// Should have file-code icon for notebooks
@@ -497,10 +515,10 @@ suite('DeepnoteTreeItem', () => {
497515
notebookId: 'notebook-1'
498516
};
499517

500-
const notebookWithDetails = {
518+
const notebookWithDetails: DeepnoteNotebook = {
501519
...mockNotebook,
502520
name: 'Data Analysis',
503-
executionMode: 'python'
521+
executionMode: 'block'
504522
};
505523

506524
const notebookItem = new DeepnoteTreeItem(
@@ -510,7 +528,7 @@ suite('DeepnoteTreeItem', () => {
510528
TreeItemCollapsibleState.None
511529
);
512530

513-
assert.strictEqual(notebookItem.tooltip, 'Notebook: Data Analysis\nExecution Mode: python');
531+
assert.strictEqual(notebookItem.tooltip, 'Notebook: Data Analysis\nExecution Mode: block');
514532
});
515533

516534
test('should handle special characters in names', () => {
@@ -520,10 +538,10 @@ suite('DeepnoteTreeItem', () => {
520538
notebookId: 'notebook-456'
521539
};
522540

523-
const notebookWithSpecialChars = {
541+
const notebookWithSpecialChars: DeepnoteNotebook = {
524542
...mockNotebook,
525543
name: 'Notebook with "quotes" & special chars',
526-
executionMode: 'python'
544+
executionMode: 'block'
527545
};
528546

529547
const item = new DeepnoteTreeItem(
@@ -533,10 +551,7 @@ suite('DeepnoteTreeItem', () => {
533551
TreeItemCollapsibleState.None
534552
);
535553

536-
assert.strictEqual(
537-
item.tooltip,
538-
'Notebook: Notebook with "quotes" & special chars\nExecution Mode: python'
539-
);
554+
assert.strictEqual(item.tooltip, 'Notebook: Notebook with "quotes" & special chars\nExecution Mode: block');
540555
});
541556
});
542557

@@ -580,7 +595,7 @@ suite('DeepnoteTreeItem', () => {
580595
);
581596

582597
// Create child notebook items
583-
const notebooks = [
598+
const notebooks: Array<{ context: DeepnoteTreeItemContext; data: DeepnoteNotebook }> = [
584599
{
585600
context: {
586601
filePath: '/workspace/research-project.deepnote',
@@ -591,7 +606,7 @@ suite('DeepnoteTreeItem', () => {
591606
id: 'analysis-notebook',
592607
name: 'Data Analysis',
593608
blocks: [],
594-
executionMode: 'python',
609+
executionMode: 'block',
595610
isModule: false
596611
}
597612
},
@@ -605,7 +620,7 @@ suite('DeepnoteTreeItem', () => {
605620
id: 'visualization-notebook',
606621
name: 'Data Visualization',
607622
blocks: [],
608-
executionMode: 'python',
623+
executionMode: 'block',
609624
isModule: false
610625
}
611626
}

src/notebooks/deepnote/deepnoteTypes.ts

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,21 @@
1+
import { DeepnoteBlock, DeepnoteFile } from '@deepnote/blocks';
2+
13
/**
2-
* Represents a complete Deepnote project structure with metadata, notebooks, and settings.
4+
* Re-export types from @deepnote/blocks for convenience.
35
*/
4-
export interface DeepnoteProject {
5-
metadata: {
6-
/** ISO timestamp when the project was created */
7-
createdAt: string;
8-
/** ISO timestamp when the project was last modified */
9-
modifiedAt: string;
10-
};
11-
project: {
12-
id: string;
13-
name: string;
14-
notebooks: DeepnoteNotebook[];
15-
settings: Record<string, unknown>;
16-
};
17-
version: string;
18-
}
6+
export type { DeepnoteBlock, DeepnoteFile };
197

208
/**
21-
* Represents a single notebook within a Deepnote project.
9+
* Alias for DeepnoteFile for backward compatibility.
10+
* @deprecated Use DeepnoteFile instead.
2211
*/
23-
export interface DeepnoteNotebook {
24-
blocks: DeepnoteBlock[];
25-
executionMode: string;
26-
id: string;
27-
isModule: boolean;
28-
name: string;
29-
workingDirectory?: string;
30-
}
12+
export type DeepnoteProject = DeepnoteFile;
3113

3214
/**
33-
* Represents a single block (cell) within a Deepnote notebook.
34-
* Can be either a code block or a markdown block.
15+
* Represents a single notebook within a Deepnote project.
16+
* Extracted from DeepnoteFile['project']['notebooks'][number].
3517
*/
36-
export interface DeepnoteBlock {
37-
blockGroup: string;
38-
content: string;
39-
executionCount?: number;
40-
id: string;
41-
metadata?: Record<string, unknown>;
42-
outputs?: DeepnoteOutput[];
43-
sortingKey: string;
44-
type: string;
45-
}
18+
export type DeepnoteNotebook = DeepnoteFile['project']['notebooks'][number];
4619

4720
/**
4821
* Represents output data generated by executing a code block.

0 commit comments

Comments
 (0)