Skip to content

Commit 5a91e78

Browse files
authored
Merge branch 'main' into jk/feat/integration-list-from-project
2 parents 4126aaf + 5c3d0f1 commit 5a91e78

14 files changed

+1852
-12
lines changed

.github/actions/create-venv-for-tests/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ runs:
1616
using: 'composite'
1717
steps:
1818
- name: Install uv
19-
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
19+
uses: astral-sh/setup-uv@2ddd2b9cb38ad8efd50337e8ab201519a34c9f24 # v7
2020

2121
# Used by tests for installation of ipykernel.
2222
# Create a venv & register it as a kernel.

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
2727

2828
- name: Setup Node.js
29-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
29+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
3030
with:
3131
cache: 'npm'
3232
node-version-file: '.nvmrc'
@@ -53,7 +53,7 @@ jobs:
5353
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
5454

5555
- name: Setup Node.js
56-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
56+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
5757
with:
5858
cache: 'npm'
5959
node-version-file: '.nvmrc'
@@ -101,7 +101,7 @@ jobs:
101101
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
102102

103103
- name: Setup Node.js
104-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
104+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
105105
with:
106106
cache: 'npm'
107107
node-version-file: '.nvmrc'
@@ -151,7 +151,7 @@ jobs:
151151
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
152152

153153
- name: Setup Node.js
154-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
154+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
155155
with:
156156
cache: 'npm'
157157
node-version-file: '.nvmrc'
@@ -175,7 +175,7 @@ jobs:
175175
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
176176

177177
- name: Setup Node.js
178-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
178+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
179179
with:
180180
cache: 'npm'
181181
node-version-file: '.nvmrc'
@@ -199,7 +199,7 @@ jobs:
199199
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
200200

201201
- name: Setup Node.js
202-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
202+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
203203
with:
204204
cache: 'npm'
205205
node-version-file: '.nvmrc'
@@ -223,7 +223,7 @@ jobs:
223223
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
224224

225225
- name: Setup Node.js
226-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
226+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
227227
with:
228228
cache: 'npm'
229229
node-version-file: '.nvmrc'

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
4040

4141
- name: Use Node ${{env.NODE_VERSION}}
42-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
42+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
4343
with:
4444
node-version-file: '.nvmrc'
4545
registry-url: 'https://npm.pkg.github.com'

.github/workflows/deps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
2525

2626
- name: Setup Node.js
27-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
27+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
2828
with:
2929
cache: 'npm'
3030
node-version-file: '.nvmrc'
@@ -57,7 +57,7 @@ jobs:
5757
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
5858

5959
- name: Setup Node.js
60-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
60+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
6161
with:
6262
node-version-file: '.nvmrc'
6363
cache: 'npm'

.github/workflows/package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
2626

2727
- name: Setup Node.js
28-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v5
28+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
2929
with:
3030
cache: 'npm'
3131
node-version-file: '.nvmrc'

renovate.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"configMigration": true,
4+
"draftPR": true,
45
"enabledManagers": ["npm", "nvm", "github-actions"],
56
"github-actions": {
67
"enabled": true,
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
import { NotebookCellData, NotebookCellKind } from 'vscode';
2+
import { z } from 'zod';
3+
4+
import type { BlockConverter } from './blockConverter';
5+
import type { DeepnoteBlock } from '../../../platform/deepnote/deepnoteTypes';
6+
import {
7+
DeepnoteTextInputMetadataSchema,
8+
DeepnoteTextareaInputMetadataSchema,
9+
DeepnoteSelectInputMetadataSchema,
10+
DeepnoteSliderInputMetadataSchema,
11+
DeepnoteCheckboxInputMetadataSchema,
12+
DeepnoteDateInputMetadataSchema,
13+
DeepnoteDateRangeInputMetadataSchema,
14+
DeepnoteFileInputMetadataSchema,
15+
DeepnoteButtonMetadataSchema
16+
} from '../deepnoteSchemas';
17+
import { parseJsonWithFallback } from '../dataConversionUtils';
18+
import { DEEPNOTE_VSCODE_RAW_CONTENT_KEY } from './constants';
19+
20+
export abstract class BaseInputBlockConverter<T extends z.ZodObject> implements BlockConverter {
21+
abstract schema(): T;
22+
abstract getSupportedType(): string;
23+
abstract defaultConfig(): z.infer<T>;
24+
25+
applyChangesToBlock(block: DeepnoteBlock, cell: NotebookCellData): void {
26+
block.content = '';
27+
28+
const config = this.schema().safeParse(parseJsonWithFallback(cell.value));
29+
30+
if (config.success !== true) {
31+
block.metadata = {
32+
...(block.metadata ?? {}),
33+
[DEEPNOTE_VSCODE_RAW_CONTENT_KEY]: cell.value
34+
};
35+
return;
36+
}
37+
38+
if (block.metadata != null) {
39+
delete block.metadata[DEEPNOTE_VSCODE_RAW_CONTENT_KEY];
40+
}
41+
42+
block.metadata = {
43+
...(block.metadata ?? {}),
44+
...config.data
45+
};
46+
}
47+
48+
canConvert(blockType: string): boolean {
49+
return blockType.toLowerCase() === this.getSupportedType();
50+
}
51+
52+
convertToCell(block: DeepnoteBlock): NotebookCellData {
53+
const deepnoteJupyterRawContentResult = z.string().safeParse(block.metadata?.[DEEPNOTE_VSCODE_RAW_CONTENT_KEY]);
54+
const deepnoteMetadataResult = this.schema().safeParse(block.metadata);
55+
56+
if (deepnoteMetadataResult.error != null) {
57+
console.error('Error parsing deepnote input metadata:', deepnoteMetadataResult.error);
58+
console.debug('Metadata:', JSON.stringify(block.metadata));
59+
}
60+
61+
const configStr = deepnoteJupyterRawContentResult.success
62+
? deepnoteJupyterRawContentResult.data
63+
: deepnoteMetadataResult.success
64+
? JSON.stringify(deepnoteMetadataResult.data, null, 2)
65+
: JSON.stringify(this.defaultConfig(), null, 2);
66+
67+
const cell = new NotebookCellData(NotebookCellKind.Code, configStr, 'json');
68+
69+
return cell;
70+
}
71+
72+
getSupportedTypes(): string[] {
73+
return [this.getSupportedType()];
74+
}
75+
}
76+
77+
export class InputTextBlockConverter extends BaseInputBlockConverter<typeof DeepnoteTextInputMetadataSchema> {
78+
private readonly DEFAULT_INPUT_TEXT_CONFIG = DeepnoteTextInputMetadataSchema.parse({});
79+
80+
schema() {
81+
return DeepnoteTextInputMetadataSchema;
82+
}
83+
getSupportedType() {
84+
return 'input-text';
85+
}
86+
defaultConfig() {
87+
return this.DEFAULT_INPUT_TEXT_CONFIG;
88+
}
89+
}
90+
91+
export class InputTextareaBlockConverter extends BaseInputBlockConverter<typeof DeepnoteTextareaInputMetadataSchema> {
92+
private readonly DEFAULT_INPUT_TEXTAREA_CONFIG = DeepnoteTextareaInputMetadataSchema.parse({});
93+
94+
schema() {
95+
return DeepnoteTextareaInputMetadataSchema;
96+
}
97+
getSupportedType() {
98+
return 'input-textarea';
99+
}
100+
defaultConfig() {
101+
return this.DEFAULT_INPUT_TEXTAREA_CONFIG;
102+
}
103+
}
104+
105+
export class InputSelectBlockConverter extends BaseInputBlockConverter<typeof DeepnoteSelectInputMetadataSchema> {
106+
private readonly DEFAULT_INPUT_SELECT_CONFIG = DeepnoteSelectInputMetadataSchema.parse({});
107+
108+
schema() {
109+
return DeepnoteSelectInputMetadataSchema;
110+
}
111+
getSupportedType() {
112+
return 'input-select';
113+
}
114+
defaultConfig() {
115+
return this.DEFAULT_INPUT_SELECT_CONFIG;
116+
}
117+
}
118+
119+
export class InputSliderBlockConverter extends BaseInputBlockConverter<typeof DeepnoteSliderInputMetadataSchema> {
120+
private readonly DEFAULT_INPUT_SLIDER_CONFIG = DeepnoteSliderInputMetadataSchema.parse({});
121+
122+
schema() {
123+
return DeepnoteSliderInputMetadataSchema;
124+
}
125+
getSupportedType() {
126+
return 'input-slider';
127+
}
128+
defaultConfig() {
129+
return this.DEFAULT_INPUT_SLIDER_CONFIG;
130+
}
131+
}
132+
133+
export class InputCheckboxBlockConverter extends BaseInputBlockConverter<typeof DeepnoteCheckboxInputMetadataSchema> {
134+
private readonly DEFAULT_INPUT_CHECKBOX_CONFIG = DeepnoteCheckboxInputMetadataSchema.parse({});
135+
136+
schema() {
137+
return DeepnoteCheckboxInputMetadataSchema;
138+
}
139+
getSupportedType() {
140+
return 'input-checkbox';
141+
}
142+
defaultConfig() {
143+
return this.DEFAULT_INPUT_CHECKBOX_CONFIG;
144+
}
145+
}
146+
147+
export class InputDateBlockConverter extends BaseInputBlockConverter<typeof DeepnoteDateInputMetadataSchema> {
148+
private readonly DEFAULT_INPUT_DATE_CONFIG = DeepnoteDateInputMetadataSchema.parse({});
149+
150+
schema() {
151+
return DeepnoteDateInputMetadataSchema;
152+
}
153+
getSupportedType() {
154+
return 'input-date';
155+
}
156+
defaultConfig() {
157+
return this.DEFAULT_INPUT_DATE_CONFIG;
158+
}
159+
}
160+
161+
export class InputDateRangeBlockConverter extends BaseInputBlockConverter<typeof DeepnoteDateRangeInputMetadataSchema> {
162+
private readonly DEFAULT_INPUT_DATE_RANGE_CONFIG = DeepnoteDateRangeInputMetadataSchema.parse({});
163+
164+
schema() {
165+
return DeepnoteDateRangeInputMetadataSchema;
166+
}
167+
getSupportedType() {
168+
return 'input-date-range';
169+
}
170+
defaultConfig() {
171+
return this.DEFAULT_INPUT_DATE_RANGE_CONFIG;
172+
}
173+
}
174+
175+
export class InputFileBlockConverter extends BaseInputBlockConverter<typeof DeepnoteFileInputMetadataSchema> {
176+
private readonly DEFAULT_INPUT_FILE_CONFIG = DeepnoteFileInputMetadataSchema.parse({});
177+
178+
schema() {
179+
return DeepnoteFileInputMetadataSchema;
180+
}
181+
getSupportedType() {
182+
return 'input-file';
183+
}
184+
defaultConfig() {
185+
return this.DEFAULT_INPUT_FILE_CONFIG;
186+
}
187+
}
188+
189+
export class ButtonBlockConverter extends BaseInputBlockConverter<typeof DeepnoteButtonMetadataSchema> {
190+
private readonly DEFAULT_BUTTON_CONFIG = DeepnoteButtonMetadataSchema.parse({});
191+
192+
schema() {
193+
return DeepnoteButtonMetadataSchema;
194+
}
195+
getSupportedType() {
196+
return 'button';
197+
}
198+
defaultConfig() {
199+
return this.DEFAULT_BUTTON_CONFIG;
200+
}
201+
}

0 commit comments

Comments
 (0)