Constructs a `DeepnoteFile`, optionally declaring an init notebook.
(args: {
projectId: string
projectName?: string
initNotebookId?: string
notebooks: Array<{
id: string
name: string
blocks?: Array<{ id: string; type?: string }>
}>
integrations?: Array<{ id: string; name: string; type: string }>
settings?: Record<string, unknown>
})
| 14 | |
| 15 | /** Constructs a `DeepnoteFile`, optionally declaring an init notebook. */ |
| 16 | function makeFile(args: { |
| 17 | projectId: string |
| 18 | projectName?: string |
| 19 | initNotebookId?: string |
| 20 | notebooks: Array<{ |
| 21 | id: string |
| 22 | name: string |
| 23 | blocks?: Array<{ id: string; type?: string }> |
| 24 | }> |
| 25 | integrations?: Array<{ id: string; name: string; type: string }> |
| 26 | settings?: Record<string, unknown> |
| 27 | }): DeepnoteFile { |
| 28 | return { |
| 29 | version: '1.0.0', |
| 30 | metadata: { createdAt: '2025-01-01T00:00:00Z' }, |
| 31 | project: { |
| 32 | id: args.projectId, |
| 33 | name: args.projectName ?? 'Test Project', |
| 34 | ...(args.initNotebookId !== undefined ? { initNotebookId: args.initNotebookId } : {}), |
| 35 | ...(args.integrations !== undefined ? { integrations: args.integrations } : {}), |
| 36 | ...(args.settings !== undefined ? { settings: args.settings } : {}), |
| 37 | notebooks: args.notebooks.map(nb => ({ |
| 38 | id: nb.id, |
| 39 | name: nb.name, |
| 40 | blocks: (nb.blocks ?? []).map((b, i) => ({ |
| 41 | id: b.id, |
| 42 | type: (b.type ?? 'code') as 'code', |
| 43 | blockGroup: `bg-${b.id}`, |
| 44 | sortingKey: `00${i}`, |
| 45 | content: `# ${b.id}`, |
| 46 | metadata: {}, |
| 47 | })), |
| 48 | })), |
| 49 | }, |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | /** Wraps a `DeepnoteFile` as the `LoadedRunnableFile` the resolver consumes. */ |
| 54 | function makeLoaded(file: DeepnoteFile, originalPath: string, format: RunnableFormat = 'deepnote'): LoadedRunnableFile { |