@deepnote/convert 1.3.0 → 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/dist/bin.js +1 -1
- package/dist/index.d.ts +633 -2
- package/dist/index.js +1 -1
- package/dist/{src-j4HyYJfD.js → src-DgOsAHcf.js} +34 -4
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as convertDeepnoteFileToJupyterFiles, t as convertIpynbFilesToDeepnoteFile } from "./src-
|
|
2
|
+
import { a as convertDeepnoteFileToJupyterFiles, t as convertIpynbFilesToDeepnoteFile } from "./src-DgOsAHcf.js";
|
|
3
3
|
import { cli } from "cleye";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { basename, extname, resolve } from "node:path";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,634 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
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
|
|
3
631
|
//#region src/types/jupyter.d.ts
|
|
4
|
-
|
|
5
632
|
/**
|
|
6
633
|
* Shared Jupyter Notebook type definitions used by both
|
|
7
634
|
* deepnote-to-jupyter and jupyter-to-deepnote converters.
|
|
@@ -54,6 +681,10 @@ interface ConvertBlocksToJupyterOptions {
|
|
|
54
681
|
isModule?: boolean;
|
|
55
682
|
/** Working directory for the notebook */
|
|
56
683
|
workingDirectory?: string;
|
|
684
|
+
/** Environment snapshot metadata */
|
|
685
|
+
environment?: Environment;
|
|
686
|
+
/** Execution snapshot metadata */
|
|
687
|
+
execution?: Execution;
|
|
57
688
|
}
|
|
58
689
|
/**
|
|
59
690
|
* Converts an array of Deepnote blocks into a single Jupyter Notebook.
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as convertDeepnoteFileToJupyterFiles, i as convertBlocksToJupyterNotebook, n as convertJupyterNotebookToBlocks, o as convertDeepnoteToJupyterNotebooks, r as convertJupyterNotebooksToDeepnote, t as convertIpynbFilesToDeepnoteFile } from "./src-
|
|
1
|
+
import { a as convertDeepnoteFileToJupyterFiles, i as convertBlocksToJupyterNotebook, n as convertJupyterNotebookToBlocks, o as convertDeepnoteToJupyterNotebooks, r as convertJupyterNotebooksToDeepnote, t as convertIpynbFilesToDeepnoteFile } from "./src-DgOsAHcf.js";
|
|
2
2
|
|
|
3
3
|
export { convertBlocksToJupyterNotebook, convertDeepnoteFileToJupyterFiles as convertDeepnoteFileToJupyter, convertDeepnoteToJupyterNotebooks, convertIpynbFilesToDeepnoteFile, convertJupyterNotebookToBlocks, convertJupyterNotebooksToDeepnote };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import { basename, dirname, extname, join } from "node:path";
|
|
3
|
-
import { createMarkdown, createPythonCode, deserializeDeepnoteFile } from "@deepnote/blocks";
|
|
3
|
+
import { createMarkdown, createPythonCode, deserializeDeepnoteFile, environmentSchema, executionSchema } from "@deepnote/blocks";
|
|
4
4
|
import { v4 } from "uuid";
|
|
5
5
|
import { stringify } from "yaml";
|
|
6
6
|
|
|
@@ -32,7 +32,9 @@ function convertBlocksToJupyterNotebook(blocks, options) {
|
|
|
32
32
|
deepnote_notebook_name: options.notebookName,
|
|
33
33
|
deepnote_execution_mode: options.executionMode,
|
|
34
34
|
deepnote_is_module: options.isModule,
|
|
35
|
-
deepnote_working_directory: options.workingDirectory
|
|
35
|
+
deepnote_working_directory: options.workingDirectory,
|
|
36
|
+
deepnote_environment: options.environment,
|
|
37
|
+
deepnote_execution: options.execution
|
|
36
38
|
},
|
|
37
39
|
nbformat: 4,
|
|
38
40
|
nbformat_minor: 0
|
|
@@ -89,6 +91,9 @@ function convertBlockToCell(block) {
|
|
|
89
91
|
deepnote_block_group: block.blockGroup,
|
|
90
92
|
deepnote_cell_type: block.type,
|
|
91
93
|
deepnote_sorting_key: block.sortingKey,
|
|
94
|
+
deepnote_content_hash: block.contentHash,
|
|
95
|
+
deepnote_execution_started_at: block.executionStartedAt,
|
|
96
|
+
deepnote_execution_finished_at: block.executionFinishedAt,
|
|
92
97
|
...block.metadata || {}
|
|
93
98
|
};
|
|
94
99
|
metadata.deepnote_source = content;
|
|
@@ -118,13 +123,15 @@ function convertBlockTypeToJupyter(blockType) {
|
|
|
118
123
|
if (blockType.startsWith("input-")) return "code";
|
|
119
124
|
return codeTypes.includes(blockType) ? "code" : "markdown";
|
|
120
125
|
}
|
|
121
|
-
function convertNotebookToJupyter(
|
|
126
|
+
function convertNotebookToJupyter(deepnoteFile, notebook) {
|
|
122
127
|
return convertBlocksToJupyterNotebook(notebook.blocks, {
|
|
123
128
|
notebookId: notebook.id,
|
|
124
129
|
notebookName: notebook.name,
|
|
125
130
|
executionMode: notebook.executionMode,
|
|
126
131
|
isModule: notebook.isModule,
|
|
127
|
-
workingDirectory: notebook.workingDirectory
|
|
132
|
+
workingDirectory: notebook.workingDirectory,
|
|
133
|
+
environment: deepnoteFile.environment,
|
|
134
|
+
execution: deepnoteFile.execution
|
|
128
135
|
});
|
|
129
136
|
}
|
|
130
137
|
function sanitizeFileName(name) {
|
|
@@ -164,7 +171,21 @@ function convertJupyterNotebookToBlocks(notebook, options) {
|
|
|
164
171
|
* @returns A DeepnoteFile object
|
|
165
172
|
*/
|
|
166
173
|
function convertJupyterNotebooksToDeepnote(notebooks, options) {
|
|
174
|
+
let environment;
|
|
175
|
+
let execution;
|
|
176
|
+
for (const { notebook } of notebooks) {
|
|
177
|
+
if (!environment && notebook.metadata?.deepnote_environment) {
|
|
178
|
+
const parsed = environmentSchema.safeParse(notebook.metadata.deepnote_environment);
|
|
179
|
+
if (parsed.success) environment = parsed.data;
|
|
180
|
+
}
|
|
181
|
+
if (!execution && notebook.metadata?.deepnote_execution) {
|
|
182
|
+
const parsed = executionSchema.safeParse(notebook.metadata.deepnote_execution);
|
|
183
|
+
if (parsed.success) execution = parsed.data;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
167
186
|
const deepnoteFile = {
|
|
187
|
+
environment,
|
|
188
|
+
execution,
|
|
168
189
|
metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() },
|
|
169
190
|
project: {
|
|
170
191
|
id: v4(),
|
|
@@ -232,6 +253,9 @@ function convertCellToBlock(cell, index, idGenerator) {
|
|
|
232
253
|
const cellId = cell.metadata?.cell_id;
|
|
233
254
|
const deepnoteCellType = cell.metadata?.deepnote_cell_type;
|
|
234
255
|
const sortingKey = cell.metadata?.deepnote_sorting_key;
|
|
256
|
+
const contentHash = cell.metadata?.deepnote_content_hash;
|
|
257
|
+
const executionStartedAt = cell.metadata?.deepnote_execution_started_at;
|
|
258
|
+
const executionFinishedAt = cell.metadata?.deepnote_execution_finished_at;
|
|
235
259
|
const blockGroup = cell.metadata?.deepnote_block_group ?? cell.block_group ?? idGenerator();
|
|
236
260
|
const deepnoteSource = cell.metadata?.deepnote_source;
|
|
237
261
|
if (deepnoteSource !== void 0) source = deepnoteSource;
|
|
@@ -242,6 +266,9 @@ function convertCellToBlock(cell, index, idGenerator) {
|
|
|
242
266
|
delete originalMetadata.deepnote_block_group;
|
|
243
267
|
delete originalMetadata.deepnote_sorting_key;
|
|
244
268
|
delete originalMetadata.deepnote_source;
|
|
269
|
+
delete originalMetadata.deepnote_content_hash;
|
|
270
|
+
delete originalMetadata.deepnote_execution_started_at;
|
|
271
|
+
delete originalMetadata.deepnote_execution_finished_at;
|
|
245
272
|
delete cell.block_group;
|
|
246
273
|
const executionCount = cell.execution_count ?? void 0;
|
|
247
274
|
const hasExecutionCount = executionCount !== void 0;
|
|
@@ -249,7 +276,10 @@ function convertCellToBlock(cell, index, idGenerator) {
|
|
|
249
276
|
return {
|
|
250
277
|
blockGroup,
|
|
251
278
|
content: source,
|
|
279
|
+
...contentHash ? { contentHash } : {},
|
|
252
280
|
...hasExecutionCount ? { executionCount } : {},
|
|
281
|
+
...executionFinishedAt ? { executionFinishedAt } : {},
|
|
282
|
+
...executionStartedAt ? { executionStartedAt } : {},
|
|
253
283
|
id: cellId ?? idGenerator(),
|
|
254
284
|
metadata: originalMetadata,
|
|
255
285
|
...hasOutputs ? { outputs: cell.outputs } : {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepnote/convert",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"ora": "^9.0.0",
|
|
34
34
|
"uuid": "^13.0.0",
|
|
35
35
|
"yaml": "^2.8.1",
|
|
36
|
-
"@deepnote/blocks": "1.
|
|
36
|
+
"@deepnote/blocks": "1.4.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^22.0.0",
|