@deepnote/convert 1.2.1 → 1.4.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/README.md +93 -13
- package/dist/bin.js +14 -2
- package/dist/index.d.ts +779 -1
- package/dist/index.js +2 -2
- package/dist/src-DgOsAHcf.js +309 -0
- package/package.json +5 -4
- package/dist/src-n1bYyJ74.js +0 -87
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,789 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region ../blocks/src/deserialize-file/deepnote-file-schema.d.ts
|
|
4
|
+
declare const deepnoteBlockSchema: z.ZodObject<{
|
|
5
|
+
blockGroup: z.ZodOptional<z.ZodString>;
|
|
6
|
+
content: z.ZodOptional<z.ZodString>;
|
|
7
|
+
contentHash: z.ZodOptional<z.ZodString>;
|
|
8
|
+
executionCount: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
executionFinishedAt: z.ZodOptional<z.ZodString>;
|
|
10
|
+
executionStartedAt: z.ZodOptional<z.ZodString>;
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
13
|
+
outputs: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
14
|
+
sortingKey: z.ZodString;
|
|
15
|
+
type: z.ZodString;
|
|
16
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
id: string;
|
|
19
|
+
type: string;
|
|
20
|
+
sortingKey: string;
|
|
21
|
+
blockGroup?: string | undefined;
|
|
22
|
+
content?: string | undefined;
|
|
23
|
+
contentHash?: string | undefined;
|
|
24
|
+
executionCount?: number | undefined;
|
|
25
|
+
executionFinishedAt?: string | undefined;
|
|
26
|
+
executionStartedAt?: string | undefined;
|
|
27
|
+
metadata?: Record<string, any> | undefined;
|
|
28
|
+
outputs?: any[] | undefined;
|
|
29
|
+
version?: number | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
id: string;
|
|
32
|
+
type: string;
|
|
33
|
+
sortingKey: string;
|
|
34
|
+
blockGroup?: string | undefined;
|
|
35
|
+
content?: string | undefined;
|
|
36
|
+
contentHash?: string | undefined;
|
|
37
|
+
executionCount?: number | undefined;
|
|
38
|
+
executionFinishedAt?: string | undefined;
|
|
39
|
+
executionStartedAt?: string | undefined;
|
|
40
|
+
metadata?: Record<string, any> | undefined;
|
|
41
|
+
outputs?: any[] | undefined;
|
|
42
|
+
version?: number | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
type DeepnoteBlock = z.infer<typeof deepnoteBlockSchema>;
|
|
45
|
+
declare const environmentSchema: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
customImage: z.ZodOptional<z.ZodString>;
|
|
47
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
48
|
+
packages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
49
|
+
platform: z.ZodOptional<z.ZodString>;
|
|
50
|
+
python: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
environment: z.ZodOptional<z.ZodEnum<["uv", "conda", "venv", "poetry", "system"]>>;
|
|
52
|
+
version: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
version?: string | undefined;
|
|
55
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
version?: string | undefined;
|
|
58
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
59
|
+
}>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
customImage?: string | undefined;
|
|
62
|
+
hash?: string | undefined;
|
|
63
|
+
packages?: Record<string, string> | undefined;
|
|
64
|
+
platform?: string | undefined;
|
|
65
|
+
python?: {
|
|
66
|
+
version?: string | undefined;
|
|
67
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
68
|
+
} | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
customImage?: string | undefined;
|
|
71
|
+
hash?: string | undefined;
|
|
72
|
+
packages?: Record<string, string> | undefined;
|
|
73
|
+
platform?: string | undefined;
|
|
74
|
+
python?: {
|
|
75
|
+
version?: string | undefined;
|
|
76
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
}>>;
|
|
79
|
+
type Environment = z.infer<typeof environmentSchema>;
|
|
80
|
+
declare const executionSchema: z.ZodOptional<z.ZodObject<{
|
|
81
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
82
|
+
message: z.ZodOptional<z.ZodString>;
|
|
83
|
+
name: z.ZodOptional<z.ZodString>;
|
|
84
|
+
traceback: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
message?: string | undefined;
|
|
87
|
+
name?: string | undefined;
|
|
88
|
+
traceback?: string[] | undefined;
|
|
89
|
+
}, {
|
|
90
|
+
message?: string | undefined;
|
|
91
|
+
name?: string | undefined;
|
|
92
|
+
traceback?: string[] | undefined;
|
|
93
|
+
}>>;
|
|
94
|
+
finishedAt: z.ZodOptional<z.ZodString>;
|
|
95
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
96
|
+
startedAt: z.ZodOptional<z.ZodString>;
|
|
97
|
+
summary: z.ZodOptional<z.ZodObject<{
|
|
98
|
+
blocksExecuted: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
blocksFailed: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
blocksSucceeded: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
totalDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
blocksExecuted?: number | undefined;
|
|
104
|
+
blocksFailed?: number | undefined;
|
|
105
|
+
blocksSucceeded?: number | undefined;
|
|
106
|
+
totalDurationMs?: number | undefined;
|
|
107
|
+
}, {
|
|
108
|
+
blocksExecuted?: number | undefined;
|
|
109
|
+
blocksFailed?: number | undefined;
|
|
110
|
+
blocksSucceeded?: number | undefined;
|
|
111
|
+
totalDurationMs?: number | undefined;
|
|
112
|
+
}>>;
|
|
113
|
+
triggeredBy: z.ZodOptional<z.ZodEnum<["user", "schedule", "api", "ci"]>>;
|
|
114
|
+
}, "strip", z.ZodTypeAny, {
|
|
115
|
+
error?: {
|
|
116
|
+
message?: string | undefined;
|
|
117
|
+
name?: string | undefined;
|
|
118
|
+
traceback?: string[] | undefined;
|
|
119
|
+
} | undefined;
|
|
120
|
+
finishedAt?: string | undefined;
|
|
121
|
+
inputs?: Record<string, unknown> | undefined;
|
|
122
|
+
startedAt?: string | undefined;
|
|
123
|
+
summary?: {
|
|
124
|
+
blocksExecuted?: number | undefined;
|
|
125
|
+
blocksFailed?: number | undefined;
|
|
126
|
+
blocksSucceeded?: number | undefined;
|
|
127
|
+
totalDurationMs?: number | undefined;
|
|
128
|
+
} | undefined;
|
|
129
|
+
triggeredBy?: "user" | "schedule" | "api" | "ci" | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
error?: {
|
|
132
|
+
message?: string | undefined;
|
|
133
|
+
name?: string | undefined;
|
|
134
|
+
traceback?: string[] | undefined;
|
|
135
|
+
} | undefined;
|
|
136
|
+
finishedAt?: string | undefined;
|
|
137
|
+
inputs?: Record<string, unknown> | undefined;
|
|
138
|
+
startedAt?: string | undefined;
|
|
139
|
+
summary?: {
|
|
140
|
+
blocksExecuted?: number | undefined;
|
|
141
|
+
blocksFailed?: number | undefined;
|
|
142
|
+
blocksSucceeded?: number | undefined;
|
|
143
|
+
totalDurationMs?: number | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
triggeredBy?: "user" | "schedule" | "api" | "ci" | undefined;
|
|
146
|
+
}>>;
|
|
147
|
+
type Execution = z.infer<typeof executionSchema>;
|
|
148
|
+
declare const deepnoteFileSchema: z.ZodObject<{
|
|
149
|
+
environment: z.ZodOptional<z.ZodObject<{
|
|
150
|
+
customImage: z.ZodOptional<z.ZodString>;
|
|
151
|
+
hash: z.ZodOptional<z.ZodString>;
|
|
152
|
+
packages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
153
|
+
platform: z.ZodOptional<z.ZodString>;
|
|
154
|
+
python: z.ZodOptional<z.ZodObject<{
|
|
155
|
+
environment: z.ZodOptional<z.ZodEnum<["uv", "conda", "venv", "poetry", "system"]>>;
|
|
156
|
+
version: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
version?: string | undefined;
|
|
159
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
160
|
+
}, {
|
|
161
|
+
version?: string | undefined;
|
|
162
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
163
|
+
}>>;
|
|
164
|
+
}, "strip", z.ZodTypeAny, {
|
|
165
|
+
customImage?: string | undefined;
|
|
166
|
+
hash?: string | undefined;
|
|
167
|
+
packages?: Record<string, string> | undefined;
|
|
168
|
+
platform?: string | undefined;
|
|
169
|
+
python?: {
|
|
170
|
+
version?: string | undefined;
|
|
171
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
172
|
+
} | undefined;
|
|
173
|
+
}, {
|
|
174
|
+
customImage?: string | undefined;
|
|
175
|
+
hash?: string | undefined;
|
|
176
|
+
packages?: Record<string, string> | undefined;
|
|
177
|
+
platform?: string | undefined;
|
|
178
|
+
python?: {
|
|
179
|
+
version?: string | undefined;
|
|
180
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
181
|
+
} | undefined;
|
|
182
|
+
}>>;
|
|
183
|
+
execution: z.ZodOptional<z.ZodObject<{
|
|
184
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
185
|
+
message: z.ZodOptional<z.ZodString>;
|
|
186
|
+
name: z.ZodOptional<z.ZodString>;
|
|
187
|
+
traceback: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
188
|
+
}, "strip", z.ZodTypeAny, {
|
|
189
|
+
message?: string | undefined;
|
|
190
|
+
name?: string | undefined;
|
|
191
|
+
traceback?: string[] | undefined;
|
|
192
|
+
}, {
|
|
193
|
+
message?: string | undefined;
|
|
194
|
+
name?: string | undefined;
|
|
195
|
+
traceback?: string[] | undefined;
|
|
196
|
+
}>>;
|
|
197
|
+
finishedAt: z.ZodOptional<z.ZodString>;
|
|
198
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
199
|
+
startedAt: z.ZodOptional<z.ZodString>;
|
|
200
|
+
summary: z.ZodOptional<z.ZodObject<{
|
|
201
|
+
blocksExecuted: z.ZodOptional<z.ZodNumber>;
|
|
202
|
+
blocksFailed: z.ZodOptional<z.ZodNumber>;
|
|
203
|
+
blocksSucceeded: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
totalDurationMs: z.ZodOptional<z.ZodNumber>;
|
|
205
|
+
}, "strip", z.ZodTypeAny, {
|
|
206
|
+
blocksExecuted?: number | undefined;
|
|
207
|
+
blocksFailed?: number | undefined;
|
|
208
|
+
blocksSucceeded?: number | undefined;
|
|
209
|
+
totalDurationMs?: number | undefined;
|
|
210
|
+
}, {
|
|
211
|
+
blocksExecuted?: number | undefined;
|
|
212
|
+
blocksFailed?: number | undefined;
|
|
213
|
+
blocksSucceeded?: number | undefined;
|
|
214
|
+
totalDurationMs?: number | undefined;
|
|
215
|
+
}>>;
|
|
216
|
+
triggeredBy: z.ZodOptional<z.ZodEnum<["user", "schedule", "api", "ci"]>>;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
error?: {
|
|
219
|
+
message?: string | undefined;
|
|
220
|
+
name?: string | undefined;
|
|
221
|
+
traceback?: string[] | undefined;
|
|
222
|
+
} | undefined;
|
|
223
|
+
finishedAt?: string | undefined;
|
|
224
|
+
inputs?: Record<string, unknown> | undefined;
|
|
225
|
+
startedAt?: string | undefined;
|
|
226
|
+
summary?: {
|
|
227
|
+
blocksExecuted?: number | undefined;
|
|
228
|
+
blocksFailed?: number | undefined;
|
|
229
|
+
blocksSucceeded?: number | undefined;
|
|
230
|
+
totalDurationMs?: number | undefined;
|
|
231
|
+
} | undefined;
|
|
232
|
+
triggeredBy?: "user" | "schedule" | "api" | "ci" | undefined;
|
|
233
|
+
}, {
|
|
234
|
+
error?: {
|
|
235
|
+
message?: string | undefined;
|
|
236
|
+
name?: string | undefined;
|
|
237
|
+
traceback?: string[] | undefined;
|
|
238
|
+
} | undefined;
|
|
239
|
+
finishedAt?: string | undefined;
|
|
240
|
+
inputs?: Record<string, unknown> | undefined;
|
|
241
|
+
startedAt?: string | undefined;
|
|
242
|
+
summary?: {
|
|
243
|
+
blocksExecuted?: number | undefined;
|
|
244
|
+
blocksFailed?: number | undefined;
|
|
245
|
+
blocksSucceeded?: number | undefined;
|
|
246
|
+
totalDurationMs?: number | undefined;
|
|
247
|
+
} | undefined;
|
|
248
|
+
triggeredBy?: "user" | "schedule" | "api" | "ci" | undefined;
|
|
249
|
+
}>>;
|
|
250
|
+
metadata: z.ZodObject<{
|
|
251
|
+
checksum: z.ZodOptional<z.ZodString>;
|
|
252
|
+
createdAt: z.ZodString;
|
|
253
|
+
exportedAt: z.ZodOptional<z.ZodString>;
|
|
254
|
+
modifiedAt: z.ZodOptional<z.ZodString>;
|
|
255
|
+
}, "strip", z.ZodTypeAny, {
|
|
256
|
+
createdAt: string;
|
|
257
|
+
checksum?: string | undefined;
|
|
258
|
+
exportedAt?: string | undefined;
|
|
259
|
+
modifiedAt?: string | undefined;
|
|
260
|
+
}, {
|
|
261
|
+
createdAt: string;
|
|
262
|
+
checksum?: string | undefined;
|
|
263
|
+
exportedAt?: string | undefined;
|
|
264
|
+
modifiedAt?: string | undefined;
|
|
265
|
+
}>;
|
|
266
|
+
project: z.ZodObject<{
|
|
267
|
+
id: z.ZodString;
|
|
268
|
+
initNotebookId: z.ZodOptional<z.ZodString>;
|
|
269
|
+
integrations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
270
|
+
id: z.ZodString;
|
|
271
|
+
name: z.ZodString;
|
|
272
|
+
type: z.ZodString;
|
|
273
|
+
}, "strip", z.ZodTypeAny, {
|
|
274
|
+
id: string;
|
|
275
|
+
type: string;
|
|
276
|
+
name: string;
|
|
277
|
+
}, {
|
|
278
|
+
id: string;
|
|
279
|
+
type: string;
|
|
280
|
+
name: string;
|
|
281
|
+
}>, "many">>;
|
|
282
|
+
name: z.ZodString;
|
|
283
|
+
notebooks: z.ZodArray<z.ZodObject<{
|
|
284
|
+
blocks: z.ZodArray<z.ZodObject<{
|
|
285
|
+
blockGroup: z.ZodOptional<z.ZodString>;
|
|
286
|
+
content: z.ZodOptional<z.ZodString>;
|
|
287
|
+
contentHash: z.ZodOptional<z.ZodString>;
|
|
288
|
+
executionCount: z.ZodOptional<z.ZodNumber>;
|
|
289
|
+
executionFinishedAt: z.ZodOptional<z.ZodString>;
|
|
290
|
+
executionStartedAt: z.ZodOptional<z.ZodString>;
|
|
291
|
+
id: z.ZodString;
|
|
292
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
293
|
+
outputs: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
294
|
+
sortingKey: z.ZodString;
|
|
295
|
+
type: z.ZodString;
|
|
296
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
297
|
+
}, "strip", z.ZodTypeAny, {
|
|
298
|
+
id: string;
|
|
299
|
+
type: string;
|
|
300
|
+
sortingKey: string;
|
|
301
|
+
blockGroup?: string | undefined;
|
|
302
|
+
content?: string | undefined;
|
|
303
|
+
contentHash?: string | undefined;
|
|
304
|
+
executionCount?: number | undefined;
|
|
305
|
+
executionFinishedAt?: string | undefined;
|
|
306
|
+
executionStartedAt?: string | undefined;
|
|
307
|
+
metadata?: Record<string, any> | undefined;
|
|
308
|
+
outputs?: any[] | undefined;
|
|
309
|
+
version?: number | undefined;
|
|
310
|
+
}, {
|
|
311
|
+
id: string;
|
|
312
|
+
type: string;
|
|
313
|
+
sortingKey: string;
|
|
314
|
+
blockGroup?: string | undefined;
|
|
315
|
+
content?: string | undefined;
|
|
316
|
+
contentHash?: string | undefined;
|
|
317
|
+
executionCount?: number | undefined;
|
|
318
|
+
executionFinishedAt?: string | undefined;
|
|
319
|
+
executionStartedAt?: string | undefined;
|
|
320
|
+
metadata?: Record<string, any> | undefined;
|
|
321
|
+
outputs?: any[] | undefined;
|
|
322
|
+
version?: number | undefined;
|
|
323
|
+
}>, "many">;
|
|
324
|
+
executionMode: z.ZodOptional<z.ZodEnum<["block", "downstream"]>>;
|
|
325
|
+
id: z.ZodString;
|
|
326
|
+
isModule: z.ZodOptional<z.ZodBoolean>;
|
|
327
|
+
name: z.ZodString;
|
|
328
|
+
workingDirectory: z.ZodOptional<z.ZodString>;
|
|
329
|
+
}, "strip", z.ZodTypeAny, {
|
|
330
|
+
id: string;
|
|
331
|
+
name: string;
|
|
332
|
+
blocks: {
|
|
333
|
+
id: string;
|
|
334
|
+
type: string;
|
|
335
|
+
sortingKey: string;
|
|
336
|
+
blockGroup?: string | undefined;
|
|
337
|
+
content?: string | undefined;
|
|
338
|
+
contentHash?: string | undefined;
|
|
339
|
+
executionCount?: number | undefined;
|
|
340
|
+
executionFinishedAt?: string | undefined;
|
|
341
|
+
executionStartedAt?: string | undefined;
|
|
342
|
+
metadata?: Record<string, any> | undefined;
|
|
343
|
+
outputs?: any[] | undefined;
|
|
344
|
+
version?: number | undefined;
|
|
345
|
+
}[];
|
|
346
|
+
executionMode?: "block" | "downstream" | undefined;
|
|
347
|
+
isModule?: boolean | undefined;
|
|
348
|
+
workingDirectory?: string | undefined;
|
|
349
|
+
}, {
|
|
350
|
+
id: string;
|
|
351
|
+
name: string;
|
|
352
|
+
blocks: {
|
|
353
|
+
id: string;
|
|
354
|
+
type: string;
|
|
355
|
+
sortingKey: string;
|
|
356
|
+
blockGroup?: string | undefined;
|
|
357
|
+
content?: string | undefined;
|
|
358
|
+
contentHash?: string | undefined;
|
|
359
|
+
executionCount?: number | undefined;
|
|
360
|
+
executionFinishedAt?: string | undefined;
|
|
361
|
+
executionStartedAt?: string | undefined;
|
|
362
|
+
metadata?: Record<string, any> | undefined;
|
|
363
|
+
outputs?: any[] | undefined;
|
|
364
|
+
version?: number | undefined;
|
|
365
|
+
}[];
|
|
366
|
+
executionMode?: "block" | "downstream" | undefined;
|
|
367
|
+
isModule?: boolean | undefined;
|
|
368
|
+
workingDirectory?: string | undefined;
|
|
369
|
+
}>, "many">;
|
|
370
|
+
settings: z.ZodOptional<z.ZodObject<{
|
|
371
|
+
/**
|
|
372
|
+
* @deprecated Use top-level `environment` instead.
|
|
373
|
+
* This field is kept for backward compatibility.
|
|
374
|
+
*/
|
|
375
|
+
environment: z.ZodOptional<z.ZodObject<{
|
|
376
|
+
customImage: z.ZodOptional<z.ZodString>;
|
|
377
|
+
pythonVersion: z.ZodOptional<z.ZodString>;
|
|
378
|
+
}, "strip", z.ZodTypeAny, {
|
|
379
|
+
customImage?: string | undefined;
|
|
380
|
+
pythonVersion?: string | undefined;
|
|
381
|
+
}, {
|
|
382
|
+
customImage?: string | undefined;
|
|
383
|
+
pythonVersion?: string | undefined;
|
|
384
|
+
}>>;
|
|
385
|
+
requirements: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
386
|
+
sqlCacheMaxAge: z.ZodOptional<z.ZodNumber>;
|
|
387
|
+
}, "strip", z.ZodTypeAny, {
|
|
388
|
+
environment?: {
|
|
389
|
+
customImage?: string | undefined;
|
|
390
|
+
pythonVersion?: string | undefined;
|
|
391
|
+
} | undefined;
|
|
392
|
+
requirements?: string[] | undefined;
|
|
393
|
+
sqlCacheMaxAge?: number | undefined;
|
|
394
|
+
}, {
|
|
395
|
+
environment?: {
|
|
396
|
+
customImage?: string | undefined;
|
|
397
|
+
pythonVersion?: string | undefined;
|
|
398
|
+
} | undefined;
|
|
399
|
+
requirements?: string[] | undefined;
|
|
400
|
+
sqlCacheMaxAge?: number | undefined;
|
|
401
|
+
}>>;
|
|
402
|
+
}, "strip", z.ZodTypeAny, {
|
|
403
|
+
id: string;
|
|
404
|
+
name: string;
|
|
405
|
+
notebooks: {
|
|
406
|
+
id: string;
|
|
407
|
+
name: string;
|
|
408
|
+
blocks: {
|
|
409
|
+
id: string;
|
|
410
|
+
type: string;
|
|
411
|
+
sortingKey: string;
|
|
412
|
+
blockGroup?: string | undefined;
|
|
413
|
+
content?: string | undefined;
|
|
414
|
+
contentHash?: string | undefined;
|
|
415
|
+
executionCount?: number | undefined;
|
|
416
|
+
executionFinishedAt?: string | undefined;
|
|
417
|
+
executionStartedAt?: string | undefined;
|
|
418
|
+
metadata?: Record<string, any> | undefined;
|
|
419
|
+
outputs?: any[] | undefined;
|
|
420
|
+
version?: number | undefined;
|
|
421
|
+
}[];
|
|
422
|
+
executionMode?: "block" | "downstream" | undefined;
|
|
423
|
+
isModule?: boolean | undefined;
|
|
424
|
+
workingDirectory?: string | undefined;
|
|
425
|
+
}[];
|
|
426
|
+
initNotebookId?: string | undefined;
|
|
427
|
+
integrations?: {
|
|
428
|
+
id: string;
|
|
429
|
+
type: string;
|
|
430
|
+
name: string;
|
|
431
|
+
}[] | undefined;
|
|
432
|
+
settings?: {
|
|
433
|
+
environment?: {
|
|
434
|
+
customImage?: string | undefined;
|
|
435
|
+
pythonVersion?: string | undefined;
|
|
436
|
+
} | undefined;
|
|
437
|
+
requirements?: string[] | undefined;
|
|
438
|
+
sqlCacheMaxAge?: number | undefined;
|
|
439
|
+
} | undefined;
|
|
440
|
+
}, {
|
|
441
|
+
id: string;
|
|
442
|
+
name: string;
|
|
443
|
+
notebooks: {
|
|
444
|
+
id: string;
|
|
445
|
+
name: string;
|
|
446
|
+
blocks: {
|
|
447
|
+
id: string;
|
|
448
|
+
type: string;
|
|
449
|
+
sortingKey: string;
|
|
450
|
+
blockGroup?: string | undefined;
|
|
451
|
+
content?: string | undefined;
|
|
452
|
+
contentHash?: string | undefined;
|
|
453
|
+
executionCount?: number | undefined;
|
|
454
|
+
executionFinishedAt?: string | undefined;
|
|
455
|
+
executionStartedAt?: string | undefined;
|
|
456
|
+
metadata?: Record<string, any> | undefined;
|
|
457
|
+
outputs?: any[] | undefined;
|
|
458
|
+
version?: number | undefined;
|
|
459
|
+
}[];
|
|
460
|
+
executionMode?: "block" | "downstream" | undefined;
|
|
461
|
+
isModule?: boolean | undefined;
|
|
462
|
+
workingDirectory?: string | undefined;
|
|
463
|
+
}[];
|
|
464
|
+
initNotebookId?: string | undefined;
|
|
465
|
+
integrations?: {
|
|
466
|
+
id: string;
|
|
467
|
+
type: string;
|
|
468
|
+
name: string;
|
|
469
|
+
}[] | undefined;
|
|
470
|
+
settings?: {
|
|
471
|
+
environment?: {
|
|
472
|
+
customImage?: string | undefined;
|
|
473
|
+
pythonVersion?: string | undefined;
|
|
474
|
+
} | undefined;
|
|
475
|
+
requirements?: string[] | undefined;
|
|
476
|
+
sqlCacheMaxAge?: number | undefined;
|
|
477
|
+
} | undefined;
|
|
478
|
+
}>;
|
|
479
|
+
version: z.ZodString;
|
|
480
|
+
}, "strip", z.ZodTypeAny, {
|
|
481
|
+
metadata: {
|
|
482
|
+
createdAt: string;
|
|
483
|
+
checksum?: string | undefined;
|
|
484
|
+
exportedAt?: string | undefined;
|
|
485
|
+
modifiedAt?: string | undefined;
|
|
486
|
+
};
|
|
487
|
+
version: string;
|
|
488
|
+
project: {
|
|
489
|
+
id: string;
|
|
490
|
+
name: string;
|
|
491
|
+
notebooks: {
|
|
492
|
+
id: string;
|
|
493
|
+
name: string;
|
|
494
|
+
blocks: {
|
|
495
|
+
id: string;
|
|
496
|
+
type: string;
|
|
497
|
+
sortingKey: string;
|
|
498
|
+
blockGroup?: string | undefined;
|
|
499
|
+
content?: string | undefined;
|
|
500
|
+
contentHash?: string | undefined;
|
|
501
|
+
executionCount?: number | undefined;
|
|
502
|
+
executionFinishedAt?: string | undefined;
|
|
503
|
+
executionStartedAt?: string | undefined;
|
|
504
|
+
metadata?: Record<string, any> | undefined;
|
|
505
|
+
outputs?: any[] | undefined;
|
|
506
|
+
version?: number | undefined;
|
|
507
|
+
}[];
|
|
508
|
+
executionMode?: "block" | "downstream" | undefined;
|
|
509
|
+
isModule?: boolean | undefined;
|
|
510
|
+
workingDirectory?: string | undefined;
|
|
511
|
+
}[];
|
|
512
|
+
initNotebookId?: string | undefined;
|
|
513
|
+
integrations?: {
|
|
514
|
+
id: string;
|
|
515
|
+
type: string;
|
|
516
|
+
name: string;
|
|
517
|
+
}[] | undefined;
|
|
518
|
+
settings?: {
|
|
519
|
+
environment?: {
|
|
520
|
+
customImage?: string | undefined;
|
|
521
|
+
pythonVersion?: string | undefined;
|
|
522
|
+
} | undefined;
|
|
523
|
+
requirements?: string[] | undefined;
|
|
524
|
+
sqlCacheMaxAge?: number | undefined;
|
|
525
|
+
} | undefined;
|
|
526
|
+
};
|
|
527
|
+
environment?: {
|
|
528
|
+
customImage?: string | undefined;
|
|
529
|
+
hash?: string | undefined;
|
|
530
|
+
packages?: Record<string, string> | undefined;
|
|
531
|
+
platform?: string | undefined;
|
|
532
|
+
python?: {
|
|
533
|
+
version?: string | undefined;
|
|
534
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
535
|
+
} | undefined;
|
|
536
|
+
} | undefined;
|
|
537
|
+
execution?: {
|
|
538
|
+
error?: {
|
|
539
|
+
message?: string | undefined;
|
|
540
|
+
name?: string | undefined;
|
|
541
|
+
traceback?: string[] | undefined;
|
|
542
|
+
} | undefined;
|
|
543
|
+
finishedAt?: string | undefined;
|
|
544
|
+
inputs?: Record<string, unknown> | undefined;
|
|
545
|
+
startedAt?: string | undefined;
|
|
546
|
+
summary?: {
|
|
547
|
+
blocksExecuted?: number | undefined;
|
|
548
|
+
blocksFailed?: number | undefined;
|
|
549
|
+
blocksSucceeded?: number | undefined;
|
|
550
|
+
totalDurationMs?: number | undefined;
|
|
551
|
+
} | undefined;
|
|
552
|
+
triggeredBy?: "user" | "schedule" | "api" | "ci" | undefined;
|
|
553
|
+
} | undefined;
|
|
554
|
+
}, {
|
|
555
|
+
metadata: {
|
|
556
|
+
createdAt: string;
|
|
557
|
+
checksum?: string | undefined;
|
|
558
|
+
exportedAt?: string | undefined;
|
|
559
|
+
modifiedAt?: string | undefined;
|
|
560
|
+
};
|
|
561
|
+
version: string;
|
|
562
|
+
project: {
|
|
563
|
+
id: string;
|
|
564
|
+
name: string;
|
|
565
|
+
notebooks: {
|
|
566
|
+
id: string;
|
|
567
|
+
name: string;
|
|
568
|
+
blocks: {
|
|
569
|
+
id: string;
|
|
570
|
+
type: string;
|
|
571
|
+
sortingKey: string;
|
|
572
|
+
blockGroup?: string | undefined;
|
|
573
|
+
content?: string | undefined;
|
|
574
|
+
contentHash?: string | undefined;
|
|
575
|
+
executionCount?: number | undefined;
|
|
576
|
+
executionFinishedAt?: string | undefined;
|
|
577
|
+
executionStartedAt?: string | undefined;
|
|
578
|
+
metadata?: Record<string, any> | undefined;
|
|
579
|
+
outputs?: any[] | undefined;
|
|
580
|
+
version?: number | undefined;
|
|
581
|
+
}[];
|
|
582
|
+
executionMode?: "block" | "downstream" | undefined;
|
|
583
|
+
isModule?: boolean | undefined;
|
|
584
|
+
workingDirectory?: string | undefined;
|
|
585
|
+
}[];
|
|
586
|
+
initNotebookId?: string | undefined;
|
|
587
|
+
integrations?: {
|
|
588
|
+
id: string;
|
|
589
|
+
type: string;
|
|
590
|
+
name: string;
|
|
591
|
+
}[] | undefined;
|
|
592
|
+
settings?: {
|
|
593
|
+
environment?: {
|
|
594
|
+
customImage?: string | undefined;
|
|
595
|
+
pythonVersion?: string | undefined;
|
|
596
|
+
} | undefined;
|
|
597
|
+
requirements?: string[] | undefined;
|
|
598
|
+
sqlCacheMaxAge?: number | undefined;
|
|
599
|
+
} | undefined;
|
|
600
|
+
};
|
|
601
|
+
environment?: {
|
|
602
|
+
customImage?: string | undefined;
|
|
603
|
+
hash?: string | undefined;
|
|
604
|
+
packages?: Record<string, string> | undefined;
|
|
605
|
+
platform?: string | undefined;
|
|
606
|
+
python?: {
|
|
607
|
+
version?: string | undefined;
|
|
608
|
+
environment?: "uv" | "conda" | "venv" | "poetry" | "system" | undefined;
|
|
609
|
+
} | undefined;
|
|
610
|
+
} | undefined;
|
|
611
|
+
execution?: {
|
|
612
|
+
error?: {
|
|
613
|
+
message?: string | undefined;
|
|
614
|
+
name?: string | undefined;
|
|
615
|
+
traceback?: string[] | undefined;
|
|
616
|
+
} | undefined;
|
|
617
|
+
finishedAt?: string | undefined;
|
|
618
|
+
inputs?: Record<string, unknown> | undefined;
|
|
619
|
+
startedAt?: string | undefined;
|
|
620
|
+
summary?: {
|
|
621
|
+
blocksExecuted?: number | undefined;
|
|
622
|
+
blocksFailed?: number | undefined;
|
|
623
|
+
blocksSucceeded?: number | undefined;
|
|
624
|
+
totalDurationMs?: number | undefined;
|
|
625
|
+
} | undefined;
|
|
626
|
+
triggeredBy?: "user" | "schedule" | "api" | "ci" | undefined;
|
|
627
|
+
} | undefined;
|
|
628
|
+
}>;
|
|
629
|
+
type DeepnoteFile = z.infer<typeof deepnoteFileSchema>;
|
|
630
|
+
//#endregion
|
|
631
|
+
//#region src/types/jupyter.d.ts
|
|
632
|
+
/**
|
|
633
|
+
* Shared Jupyter Notebook type definitions used by both
|
|
634
|
+
* deepnote-to-jupyter and jupyter-to-deepnote converters.
|
|
635
|
+
*/
|
|
636
|
+
interface JupyterCell {
|
|
637
|
+
/** Top-level block_group field present in cloud-exported notebooks */
|
|
638
|
+
block_group?: string;
|
|
639
|
+
cell_type: 'code' | 'markdown';
|
|
640
|
+
execution_count?: number | null;
|
|
641
|
+
metadata: JupyterCellMetadata;
|
|
642
|
+
outputs?: any[];
|
|
643
|
+
outputs_reference?: string;
|
|
644
|
+
source: string | string[];
|
|
645
|
+
}
|
|
646
|
+
interface JupyterCellMetadata {
|
|
647
|
+
cell_id?: string;
|
|
648
|
+
deepnote_cell_type?: string;
|
|
649
|
+
deepnote_block_group?: string;
|
|
650
|
+
deepnote_sorting_key?: string;
|
|
651
|
+
deepnote_source?: string;
|
|
652
|
+
[key: string]: unknown;
|
|
653
|
+
}
|
|
654
|
+
interface JupyterNotebook {
|
|
655
|
+
cells: JupyterCell[];
|
|
656
|
+
metadata: JupyterNotebookMetadata;
|
|
657
|
+
nbformat?: number;
|
|
658
|
+
nbformat_minor?: number;
|
|
659
|
+
}
|
|
660
|
+
interface JupyterNotebookMetadata {
|
|
661
|
+
deepnote_notebook_id?: string;
|
|
662
|
+
deepnote_notebook_name?: string;
|
|
663
|
+
deepnote_execution_mode?: 'block' | 'downstream';
|
|
664
|
+
deepnote_is_module?: boolean;
|
|
665
|
+
deepnote_working_directory?: string;
|
|
666
|
+
[key: string]: unknown;
|
|
667
|
+
}
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/deepnote-to-jupyter.d.ts
|
|
670
|
+
interface ConvertDeepnoteFileToJupyterOptions {
|
|
671
|
+
outputDir: string;
|
|
672
|
+
}
|
|
673
|
+
interface ConvertBlocksToJupyterOptions {
|
|
674
|
+
/** Unique identifier for the notebook */
|
|
675
|
+
notebookId: string;
|
|
676
|
+
/** Display name of the notebook */
|
|
677
|
+
notebookName: string;
|
|
678
|
+
/** Execution mode: 'block' runs cells individually, 'downstream' runs dependent cells */
|
|
679
|
+
executionMode?: 'block' | 'downstream';
|
|
680
|
+
/** Whether this notebook is a module (importable by other notebooks) */
|
|
681
|
+
isModule?: boolean;
|
|
682
|
+
/** Working directory for the notebook */
|
|
683
|
+
workingDirectory?: string;
|
|
684
|
+
/** Environment snapshot metadata */
|
|
685
|
+
environment?: Environment;
|
|
686
|
+
/** Execution snapshot metadata */
|
|
687
|
+
execution?: Execution;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Converts an array of Deepnote blocks into a single Jupyter Notebook.
|
|
691
|
+
* This is the lowest-level conversion function, suitable for use in Deepnote Cloud.
|
|
692
|
+
*
|
|
693
|
+
* @param blocks - Array of DeepnoteBlock objects to convert
|
|
694
|
+
* @param options - Notebook metadata options
|
|
695
|
+
* @returns A JupyterNotebook object
|
|
696
|
+
*
|
|
697
|
+
* @example
|
|
698
|
+
* ```typescript
|
|
699
|
+
* import { convertBlocksToJupyterNotebook } from '@deepnote/convert'
|
|
700
|
+
*
|
|
701
|
+
* const notebook = convertBlocksToJupyterNotebook(blocks, {
|
|
702
|
+
* notebookId: 'abc123',
|
|
703
|
+
* notebookName: 'My Notebook',
|
|
704
|
+
* executionMode: 'block'
|
|
705
|
+
* })
|
|
706
|
+
* ```
|
|
707
|
+
*/
|
|
708
|
+
declare function convertBlocksToJupyterNotebook(blocks: DeepnoteBlock[], options: ConvertBlocksToJupyterOptions): JupyterNotebook;
|
|
709
|
+
/**
|
|
710
|
+
* Converts a Deepnote project into Jupyter Notebook objects.
|
|
711
|
+
* This is a pure conversion function that doesn't perform any file I/O.
|
|
712
|
+
* Each notebook in the Deepnote project is converted to a separate Jupyter notebook.
|
|
713
|
+
*
|
|
714
|
+
* @param deepnoteFile - The deserialized Deepnote project file
|
|
715
|
+
* @returns Array of objects containing filename and corresponding Jupyter notebook
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```typescript
|
|
719
|
+
* import { deserializeDeepnoteFile } from '@deepnote/blocks'
|
|
720
|
+
* import { convertDeepnoteToJupyterNotebooks } from '@deepnote/convert'
|
|
721
|
+
*
|
|
722
|
+
* const yamlContent = await fs.readFile('project.deepnote', 'utf-8')
|
|
723
|
+
* const deepnoteFile = deserializeDeepnoteFile(yamlContent)
|
|
724
|
+
* const notebooks = convertDeepnoteToJupyterNotebooks(deepnoteFile)
|
|
725
|
+
*
|
|
726
|
+
* for (const { filename, notebook } of notebooks) {
|
|
727
|
+
* console.log(`${filename}: ${notebook.cells.length} cells`)
|
|
728
|
+
* }
|
|
729
|
+
* ```
|
|
730
|
+
*/
|
|
731
|
+
declare function convertDeepnoteToJupyterNotebooks(deepnoteFile: DeepnoteFile): Array<{
|
|
732
|
+
filename: string;
|
|
733
|
+
notebook: JupyterNotebook;
|
|
734
|
+
}>;
|
|
735
|
+
/**
|
|
736
|
+
* Converts a Deepnote project file into separate Jupyter Notebook (.ipynb) files.
|
|
737
|
+
* Each notebook in the Deepnote project becomes a separate .ipynb file.
|
|
738
|
+
*/
|
|
739
|
+
declare function convertDeepnoteFileToJupyterFiles(deepnoteFilePath: string, options: ConvertDeepnoteFileToJupyterOptions): Promise<void>;
|
|
740
|
+
//#endregion
|
|
1
741
|
//#region src/jupyter-to-deepnote.d.ts
|
|
2
742
|
interface ConvertIpynbFilesToDeepnoteFileOptions {
|
|
3
743
|
outputPath: string;
|
|
4
744
|
projectName: string;
|
|
5
745
|
}
|
|
746
|
+
interface ConvertJupyterNotebookOptions {
|
|
747
|
+
/** Custom ID generator function. Defaults to uuid v4. */
|
|
748
|
+
idGenerator?: () => string;
|
|
749
|
+
}
|
|
750
|
+
interface JupyterNotebookInput {
|
|
751
|
+
filename: string;
|
|
752
|
+
notebook: JupyterNotebook;
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Converts a single Jupyter Notebook into an array of Deepnote blocks.
|
|
756
|
+
* This is the lowest-level conversion function, suitable for use in Deepnote Cloud.
|
|
757
|
+
*
|
|
758
|
+
* @param notebook - The Jupyter notebook object to convert
|
|
759
|
+
* @param options - Optional conversion options including custom ID generator
|
|
760
|
+
* @returns Array of DeepnoteBlock objects
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* ```typescript
|
|
764
|
+
* import { convertJupyterNotebookToBlocks } from '@deepnote/convert'
|
|
765
|
+
*
|
|
766
|
+
* const notebook = JSON.parse(ipynbContent)
|
|
767
|
+
* const blocks = convertJupyterNotebookToBlocks(notebook, {
|
|
768
|
+
* idGenerator: () => myCustomIdGenerator()
|
|
769
|
+
* })
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
declare function convertJupyterNotebookToBlocks(notebook: JupyterNotebook, options?: ConvertJupyterNotebookOptions): DeepnoteBlock[];
|
|
773
|
+
/**
|
|
774
|
+
* Converts Jupyter Notebook objects into a Deepnote project file.
|
|
775
|
+
* This is a pure conversion function that doesn't perform any file I/O.
|
|
776
|
+
*
|
|
777
|
+
* @param notebooks - Array of Jupyter notebooks with filenames
|
|
778
|
+
* @param options - Conversion options including project name
|
|
779
|
+
* @returns A DeepnoteFile object
|
|
780
|
+
*/
|
|
781
|
+
declare function convertJupyterNotebooksToDeepnote(notebooks: JupyterNotebookInput[], options: {
|
|
782
|
+
projectName: string;
|
|
783
|
+
}): DeepnoteFile;
|
|
6
784
|
/**
|
|
7
785
|
* Converts multiple Jupyter Notebook (.ipynb) files into a single Deepnote project file.
|
|
8
786
|
*/
|
|
9
787
|
declare function convertIpynbFilesToDeepnoteFile(inputFilePaths: string[], options: ConvertIpynbFilesToDeepnoteFileOptions): Promise<void>;
|
|
10
788
|
//#endregion
|
|
11
|
-
export { type ConvertIpynbFilesToDeepnoteFileOptions, convertIpynbFilesToDeepnoteFile };
|
|
789
|
+
export { type ConvertBlocksToJupyterOptions, type ConvertIpynbFilesToDeepnoteFileOptions, type ConvertJupyterNotebookOptions, type JupyterCell, type JupyterNotebook, type JupyterNotebookInput, convertBlocksToJupyterNotebook, convertDeepnoteFileToJupyterFiles as convertDeepnoteFileToJupyter, convertDeepnoteToJupyterNotebooks, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote };
|