@malloy-publisher/sdk 0.9.0 → 0.9.2

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.
Files changed (292) hide show
  1. package/dist/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
  2. package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
  3. package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
  4. package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
  5. package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
  6. package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
  7. package/dist/builder/index.cjs.js +146 -58
  8. package/dist/builder/index.es.js +9076 -6479
  9. package/dist/builder-entry.d.ts +4 -0
  10. package/dist/client/api.d.ts +82 -48
  11. package/dist/client/configuration.d.ts +1 -1
  12. package/dist/client/index.cjs.js +1 -1
  13. package/dist/client/index.d.ts +1 -1
  14. package/dist/client/index.es.js +84 -82
  15. package/dist/components/Dashboard/Dashboard.d.ts +8 -15
  16. package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
  17. package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
  18. package/dist/components/Dashboard/DashboardView.d.ts +36 -0
  19. package/dist/components/Dashboard/TileCard.d.ts +15 -4
  20. package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
  21. package/dist/components/Dashboard/index.d.ts +3 -0
  22. package/dist/components/Dashboard/telemetry.d.ts +15 -3
  23. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
  24. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
  25. package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
  26. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
  27. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
  28. package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
  29. package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
  30. package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
  31. package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
  32. package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
  33. package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
  34. package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
  35. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
  36. package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
  37. package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
  38. package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
  39. package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
  40. package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
  41. package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
  42. package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
  43. package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
  44. package/dist/components/DashboardBuilder/controls.d.ts +2 -2
  45. package/dist/components/DashboardBuilder/document.d.ts +42 -26
  46. package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
  47. package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
  48. package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
  49. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
  50. package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
  51. package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
  52. package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
  53. package/dist/components/DashboardBuilder/preview.d.ts +24 -4
  54. package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
  55. package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
  56. package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
  57. package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
  58. package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
  59. package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
  60. package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
  61. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
  62. package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
  63. package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
  64. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
  65. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
  66. package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
  67. package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
  68. package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
  69. package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
  70. package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
  71. package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
  72. package/dist/components/DocumentCreate/events.d.ts +10 -0
  73. package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
  74. package/dist/components/DocumentCreate/guards.d.ts +12 -0
  75. package/dist/components/DocumentCreate/index.d.ts +6 -0
  76. package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
  77. package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
  78. package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
  79. package/dist/components/NarrowEditGate.d.ts +8 -0
  80. package/dist/components/Notebook/Notebook.d.ts +1 -1
  81. package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
  82. package/dist/components/Package/Package.d.ts +1 -0
  83. package/dist/components/Package/documentLocation.d.ts +28 -0
  84. package/dist/components/Package/index.d.ts +4 -0
  85. package/dist/components/Package/useDocumentLocation.d.ts +12 -0
  86. package/dist/components/PackageSection.d.ts +2 -2
  87. package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
  88. package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
  89. package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
  90. package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
  91. package/dist/components/ServerProvider.d.ts +2 -1
  92. package/dist/components/UnsavedChangesDialog.d.ts +9 -0
  93. package/dist/components/given/GivensPanel.d.ts +2 -2
  94. package/dist/components/index.d.ts +2 -0
  95. package/dist/hooks/index.d.ts +1 -0
  96. package/dist/hooks/useNarrowScreen.d.ts +4 -0
  97. package/dist/hooks/useQueryResult.d.ts +2 -0
  98. package/dist/hooks/useSettled.d.ts +14 -0
  99. package/dist/index.cjs.js +23 -24
  100. package/dist/index.es.js +9714 -7072
  101. package/dist/text/index.cjs.js +1 -0
  102. package/dist/text/index.d.ts +2 -0
  103. package/dist/text/index.es.js +6 -0
  104. package/dist/text-entry-BJwltZiy.cjs.js +7 -0
  105. package/dist/text-entry-CbbBcZl8.es.js +196 -0
  106. package/dist/text-entry.d.ts +2 -0
  107. package/dist/utils/clock.d.ts +2 -0
  108. package/package.json +10 -1
  109. package/src/builder-entry.ts +35 -0
  110. package/src/components/Dashboard/Dashboard.tsx +27 -278
  111. package/src/components/Dashboard/DashboardGrid.tsx +68 -7
  112. package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
  113. package/src/components/Dashboard/DashboardTile.tsx +31 -4
  114. package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
  115. package/src/components/Dashboard/DashboardView.tsx +352 -0
  116. package/src/components/Dashboard/RowsDialog.tsx +1 -1
  117. package/src/components/Dashboard/TileCard.tsx +44 -10
  118. package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
  119. package/src/components/Dashboard/TileFilterTag.tsx +78 -0
  120. package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
  121. package/src/components/Dashboard/index.ts +3 -0
  122. package/src/components/Dashboard/telemetry.ts +16 -5
  123. package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
  124. package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
  125. package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
  126. package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
  127. package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
  128. package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
  129. package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
  130. package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
  131. package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
  132. package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
  133. package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
  134. package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
  135. package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
  136. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
  137. package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
  138. package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
  139. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
  140. package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
  141. package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
  142. package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
  143. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
  144. package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
  145. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
  146. package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
  147. package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
  148. package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
  149. package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
  150. package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
  151. package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
  152. package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
  153. package/src/components/DashboardBuilder/InlineText.tsx +106 -0
  154. package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
  155. package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
  156. package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
  157. package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
  158. package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
  159. package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
  160. package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
  161. package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
  162. package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
  163. package/src/components/DashboardBuilder/annotationText.ts +17 -0
  164. package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
  165. package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
  166. package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
  167. package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
  168. package/src/components/DashboardBuilder/catalog.ts +61 -21
  169. package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
  170. package/src/components/DashboardBuilder/changedTile.ts +28 -0
  171. package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
  172. package/src/components/DashboardBuilder/chartLine.ts +121 -0
  173. package/src/components/DashboardBuilder/controls.spec.ts +21 -10
  174. package/src/components/DashboardBuilder/controls.ts +22 -8
  175. package/src/components/DashboardBuilder/document.ts +53 -5
  176. package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
  177. package/src/components/DashboardBuilder/documentSession.ts +257 -0
  178. package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
  179. package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
  180. package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
  181. package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
  182. package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
  183. package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
  184. package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
  185. package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
  186. package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
  187. package/src/components/DashboardBuilder/malloyText.ts +181 -27
  188. package/src/components/DashboardBuilder/malloyTree.ts +155 -7
  189. package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
  190. package/src/components/DashboardBuilder/newDashboard.ts +30 -3
  191. package/src/components/DashboardBuilder/openDraft.ts +52 -0
  192. package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
  193. package/src/components/DashboardBuilder/preview.spec.ts +159 -12
  194. package/src/components/DashboardBuilder/preview.ts +83 -9
  195. package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
  196. package/src/components/DashboardBuilder/readDocument.ts +130 -44
  197. package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
  198. package/src/components/DashboardBuilder/readForEditor.ts +47 -0
  199. package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
  200. package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
  201. package/src/components/DashboardBuilder/sortable.tsx +2 -12
  202. package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
  203. package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
  204. package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
  205. package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
  206. package/src/components/DashboardBuilder/spliceResult.ts +15 -0
  207. package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
  208. package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
  209. package/src/components/DashboardBuilder/tagParse.ts +103 -0
  210. package/src/components/DashboardBuilder/telemetry.ts +47 -0
  211. package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
  212. package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
  213. package/src/components/DashboardBuilder/testing/inline.ts +25 -0
  214. package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
  215. package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
  216. package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
  217. package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
  218. package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
  219. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
  220. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
  221. package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
  222. package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
  223. package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
  224. package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
  225. package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
  226. package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
  227. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
  228. package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
  229. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
  230. package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
  231. package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
  232. package/src/components/DocumentCreate/canRetry.ts +19 -0
  233. package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
  234. package/src/components/DocumentCreate/createDocument.ts +159 -0
  235. package/src/components/DocumentCreate/documentPath.ts +40 -0
  236. package/src/components/DocumentCreate/events.ts +15 -0
  237. package/src/components/DocumentCreate/exportedSources.ts +25 -0
  238. package/src/components/DocumentCreate/guards.ts +45 -0
  239. package/src/components/DocumentCreate/index.ts +27 -0
  240. package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
  241. package/src/components/DocumentCreate/newNotebook.ts +44 -0
  242. package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
  243. package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
  244. package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
  245. package/src/components/Model/ModelExplorer.spec.tsx +2 -2
  246. package/src/components/Model/SourcesExplorer.tsx +2 -4
  247. package/src/components/NarrowEditGate.spec.tsx +73 -0
  248. package/src/components/NarrowEditGate.tsx +29 -0
  249. package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
  250. package/src/components/Notebook/Notebook.tsx +66 -27
  251. package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
  252. package/src/components/Package/NewDocumentDialog.tsx +401 -0
  253. package/src/components/Package/Package.artifacts.spec.tsx +190 -0
  254. package/src/components/Package/Package.create.spec.tsx +380 -0
  255. package/src/components/Package/Package.notebooks.spec.tsx +18 -0
  256. package/src/components/Package/Package.tsx +366 -171
  257. package/src/components/Package/documentLocation.spec.ts +81 -0
  258. package/src/components/Package/documentLocation.ts +55 -0
  259. package/src/components/Package/index.ts +13 -0
  260. package/src/components/Package/useDocumentLocation.ts +59 -0
  261. package/src/components/PackageSection.tsx +2 -2
  262. package/src/components/RenderedResult/RenderedResult.tsx +18 -1
  263. package/src/components/RenderedResult/ResultContainer.tsx +44 -11
  264. package/src/components/RenderedResult/ResultPanel.tsx +4 -0
  265. package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
  266. package/src/components/RenderedResult/resultSizing.ts +14 -3
  267. package/src/components/ServerProvider.tsx +2 -1
  268. package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
  269. package/src/components/UnsavedChangesDialog.tsx +49 -0
  270. package/src/components/given/GivensPanel.spec.tsx +6 -6
  271. package/src/components/given/GivensPanel.tsx +3 -3
  272. package/src/components/index.ts +2 -0
  273. package/src/hooks/index.ts +3 -0
  274. package/src/hooks/useNarrowScreen.ts +21 -0
  275. package/src/hooks/useQueryResult.ts +16 -0
  276. package/src/hooks/useSettled.spec.ts +41 -0
  277. package/src/hooks/useSettled.ts +27 -0
  278. package/src/mainEntry.spec.ts +145 -0
  279. package/src/text-entry.ts +12 -0
  280. package/src/textEntry.spec.ts +118 -0
  281. package/src/utils/clock.spec.ts +12 -0
  282. package/src/utils/clock.ts +6 -0
  283. package/vite.config.ts +4 -0
  284. package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
  285. package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
  286. package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
  287. package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
  288. package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
  289. package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
  290. package/src/components/DashboardBuilder/useTileResize.ts +0 -110
  291. package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
  292. package/src/components/Package/NewDashboardDialog.tsx +0 -265
@@ -0,0 +1,43 @@
1
+ import { DashboardEvent } from '../Dashboard/telemetry';
2
+ import { SavesTo } from './documentSession';
3
+ import { NotebookCreatedEvent } from '../DocumentCreate/events';
4
+ /** What the notebook editor reports about itself, for the host to log; context-free like `DashboardEvent`. A one-column dashboard document reports these too. */
5
+ export type NotebookEvent = {
6
+ type: "notebook.opened";
7
+ /** The package file, or the host's own copy when that copy is the record. */
8
+ from: "package" | "record";
9
+ cells: number;
10
+ durationMs: number;
11
+ } | {
12
+ type: "notebook.open_refused";
13
+ reason: string;
14
+ } | {
15
+ type: "notebook.saved";
16
+ cells: number;
17
+ where: SavesTo;
18
+ /** The save added or removed a cell. */
19
+ structural: boolean;
20
+ /** The save rewrote a notebook in the cell format as a layout notebook. */
21
+ converted?: boolean;
22
+ /** The host workspace that took the write; never set for a package save. */
23
+ workspace?: string;
24
+ durationMs: number;
25
+ } | {
26
+ type: "notebook.save_refused";
27
+ reason: string;
28
+ } | {
29
+ /** Undo save wrote the file back as it was before the last save. */
30
+ type: "notebook.save_undone";
31
+ cells: number;
32
+ where: SavesTo;
33
+ /** Whether the save it took back added or removed a cell. */
34
+ structural: boolean;
35
+ workspace?: string;
36
+ durationMs: number;
37
+ } | {
38
+ type: "notebook.save_undo_refused";
39
+ reason: string;
40
+ } | NotebookCreatedEvent;
41
+ export type NotebookEventHandler = (event: NotebookEvent) => void;
42
+ /** Whatever the one builder reports: a notebook-kind document speaks `notebook.*`, a dashboard `dashboard.*`. */
43
+ export type BuilderEvent = DashboardEvent | NotebookEvent;
@@ -1,4 +1,4 @@
1
- import { DashboardDocument } from '../document';
1
+ import { DashboardDocument, QueryTile } from '../document';
2
2
  import { SpliceResult } from '../spliceDocument';
3
3
  /** The document a file produces, or a thrown reason: what a spec starts from. */
4
4
  export declare function openDocument(source: string): Promise<DashboardDocument>;
@@ -8,3 +8,5 @@ export declare function splice(source: string, edit: (document: DashboardDocumen
8
8
  export declare function spliced(source: string, edit: (document: DashboardDocument) => void): Promise<string>;
9
9
  /** `splice`, for an edit the writer is expected to refuse; its reason. */
10
10
  export declare function refused(source: string, edit: (document: DashboardDocument) => void): Promise<string>;
11
+ /** The query tile at `index`, for a spec that edits or reads query-only fields. */
12
+ export declare function queryTile(document: DashboardDocument, index: number): QueryTile;
@@ -0,0 +1,4 @@
1
+ /** Edit a line of text where it is shown: click it, type, and commit (Enter) or leave another way. */
2
+ export declare function editInline(shown: string, label: string, next: string, key?: "Enter" | "Escape", scope?: HTMLElement): void;
3
+ /** Close an open tile menu: Escape inside it, now that no field in it holds focus. */
4
+ export declare const closeMenu: () => boolean;
@@ -0,0 +1,89 @@
1
+ import { BuilderToolbarProps } from './BuilderToolbar';
2
+ import { BuilderShortcutHandlers } from './useBuilderShortcuts';
3
+ import { LastSave, SaveHandler, SaveOutcome } from './useDocumentEditor';
4
+ import { SaveNoticeProps } from './SaveNotice';
5
+ /** What a builder's session reads of its document editor. */
6
+ export interface SessionEditor<D, L extends LastSave = LastSave> {
7
+ document: D;
8
+ /** The document as of the last save (or open). */
9
+ saved: D;
10
+ dirty: boolean;
11
+ /** Unsaved edits made by a person, when that differs from `dirty` (an open that is unsaved before any edit); absent means `dirty`. */
12
+ edited?: boolean;
13
+ structural: boolean;
14
+ /** Whether the document opened unsaved (a conversion); the save that clears it reports so. */
15
+ pendingOpen?: boolean;
16
+ canUndo: boolean;
17
+ canRedo: boolean;
18
+ undo: () => void;
19
+ redo: () => void;
20
+ save: () => Promise<SaveOutcome>;
21
+ canUndoSave: boolean;
22
+ lastSave?: L;
23
+ undoSave: () => Promise<SaveOutcome>;
24
+ }
25
+ /** What a builder says about a save, in its own event's words. */
26
+ export interface SessionReport {
27
+ /** How many tiles or cells the document has, as the event counts them. */
28
+ size: number;
29
+ saved: (info: SessionSaveInfo) => void;
30
+ refused: (reason: string) => void;
31
+ /** An Undo save that wrote the file back. */
32
+ undone: (info: SessionSaveInfo) => void;
33
+ undoRefused: (reason: string) => void;
34
+ }
35
+ export interface SessionSaveInfo {
36
+ size: number;
37
+ structural: boolean;
38
+ /** The save wrote a document that opened unsaved. */
39
+ fromOpen: boolean;
40
+ durationMs: number;
41
+ }
42
+ export interface BuilderSessionOptions<D, L extends LastSave = LastSave> {
43
+ editor: SessionEditor<D, L>;
44
+ onSave?: SaveHandler<D>;
45
+ onExit?: () => void;
46
+ onDirtyChange?: (dirty: boolean) => void;
47
+ /** Whether the save notice is showing, on every change and on mount. */
48
+ onSaveNoticeChange?: (showing: boolean) => void;
49
+ onChange?: (document: D) => void;
50
+ /** Unsaved state the editor does not hold, such as an open text draft. */
51
+ extraDirty?: boolean;
52
+ report: SessionReport;
53
+ /** What the notice counts and calls them: "tile" or "cell". */
54
+ unit: {
55
+ name: string;
56
+ count: (document: D) => number;
57
+ };
58
+ /** Runs before every save entry point, handing it the save to run once the document is ready. */
59
+ prepare?: (run: () => Promise<void> | void) => Promise<void> | void;
60
+ /** The builder's own keys, less undo, redo and save, which the session owns. Memoized by the caller. */
61
+ shortcuts: Pick<BuilderShortcutHandlers, "escape" | "nudge">;
62
+ }
63
+ /**
64
+ * What the dashboard and notebook builders share around their document editor:
65
+ * saving (with its event and timing), the dirty and change reports, the exit
66
+ * guard, the keyboard, and the props their toolbar takes.
67
+ */
68
+ export declare function useBuilderSession<D, L extends LastSave & {
69
+ removedComments?: string[];
70
+ } = LastSave>({ editor, onSave, onExit, onDirtyChange, onSaveNoticeChange, onChange, extraDirty, report, unit, prepare, shortcuts, }: BuilderSessionOptions<D, L>): {
71
+ saving: boolean;
72
+ save: () => Promise<void> | void;
73
+ exitGuard: {
74
+ requestExit: () => void;
75
+ dialog: {
76
+ open: boolean;
77
+ canSave: boolean;
78
+ onKeepEditing: () => void;
79
+ onDiscard: () => void;
80
+ onSaveAndExit: () => void;
81
+ };
82
+ };
83
+ /** Write the file back as it was before the last save, and put the edits back unsaved. */
84
+ undoSave: () => Promise<void> | void;
85
+ canUndoSave: boolean;
86
+ lastSave: L;
87
+ notice: SaveNoticeProps;
88
+ toolbarProps: Pick<BuilderToolbarProps, "canUndo" | "canRedo" | "onUndo" | "onRedo" | "dirty" | "saving" | "onSave" | "saveButton" | "onExit">;
89
+ };
@@ -3,20 +3,23 @@
3
3
  *
4
4
  * Undo and redo on the platform's usual keys, save on ⌘S / Ctrl+S (which the
5
5
  * browser would otherwise take), Escape to drop the selection, and the arrow
6
- * keys to nudge the selected tile's width a column at a time — the one layout
7
- * edit that is otherwise drag-only.
6
+ * keys to nudge the selected tile's width a column at a time.
8
7
  *
9
- * Nothing but Escape fires while a text field has focus, so typing into a
10
- * title never undoes a layout.
8
+ * Nothing but Escape and save fires while a text field has focus, so typing
9
+ * into a title never undoes a layout. Save leaves the field first, so its
10
+ * blur commits the draft, and runs once that edit has rendered.
11
11
  */
12
12
  export interface BuilderShortcutHandlers {
13
13
  undo: () => void;
14
14
  redo: () => void;
15
15
  save?: () => void;
16
16
  escape: () => void;
17
- /** Nudge the selected tile's width by ±1 column. */
18
- nudge: (delta: 1 | -1) => void;
17
+ /** Nudge the selected tile's width by ±1 column. Absent, the arrow keys are left alone. */
18
+ nudge?: (delta: 1 | -1) => void;
19
+ /** A modal owns the keyboard: no shortcut fires, so none can open a second dialog over it. */
20
+ paused?: boolean;
19
21
  }
22
+ export declare const isMac: boolean;
20
23
  /** The modifier's glyph for a tooltip. */
21
24
  export declare const MOD: string;
22
25
  export declare function useBuilderShortcuts(handlers: BuilderShortcutHandlers): void;
@@ -1,63 +1,25 @@
1
1
  import { DashboardDocument } from './document';
2
- /**
3
- * The editor's state: the document being edited, its history, and saving.
4
- *
5
- * Deliberately holds the DOCUMENT and nothing else. Given VALUES — what the
6
- * preview is running with — are editor state rather than document state and
7
- * live outside this hook, which is what keeps them out of the undo stack. Undo
8
- * should take back a layout change; it should not rewind the filter someone was
9
- * previewing under.
10
- */
11
- export interface DashboardEditor {
12
- document: DashboardDocument;
13
- /** The file as it currently stands, which is what a save patches. */
14
- source: string;
15
- canUndo: boolean;
16
- canRedo: boolean;
17
- /** Whether the document has changes the file does not have yet. */
18
- dirty: boolean;
19
- /**
20
- * Why the last save did not happen. The document is untouched when this is
21
- * set: a refused write keeps the reader's work and reports a defect in the
22
- * writer, rather than discarding an edit because a tool could not read back
23
- * what it produced.
24
- */
25
- error?: string;
26
- /** Apply a change. Receives a copy; mutate it freely. */
27
- update: (change: (draft: DashboardDocument) => void) => void;
28
- undo: () => void;
29
- redo: () => void;
30
- /** Splice the change into the file, or say why it was refused. */
31
- save: () => Promise<SaveOutcome>;
32
- /**
33
- * The file a save would write, without writing it: what a diff preview
34
- * shows. The failure arm is the writer's refusal, worded for the author.
35
- */
36
- preview: () => Promise<{
37
- ok: true;
38
- source: string;
39
- } | {
40
- ok: false;
41
- reason: string;
42
- }>;
43
- /**
44
- * Whether the unsaved change adds or removes a tile. Those moves touch
45
- * declarations and the comments beside them, which is when a save is worth
46
- * showing as a diff first; a property edit never is.
47
- */
48
- structural: boolean;
49
- }
50
- export type SaveOutcome = {
51
- ok: true;
52
- } | {
53
- ok: false;
54
- reason: string;
55
- };
2
+ import { DocumentEditor, SaveHandler, SaveOutcome } from './useDocumentEditor';
3
+ export type DashboardEditor = DocumentEditor<DashboardDocument>;
4
+ export type { SaveOutcome };
56
5
  export declare function useDashboardEditor(options: {
57
6
  /** The file as read from storage. */
58
7
  source: string;
59
8
  /** The document that file produced. */
60
9
  document: DashboardDocument;
61
10
  /** Persist the patched file. Rejecting leaves the editor dirty. */
62
- onSave?: (source: string) => Promise<void> | void;
11
+ onSave?: SaveHandler<DashboardDocument>;
12
+ /**
13
+ * A cell-format notebook the document is the conversion of: while `source`
14
+ * is `from` the edits are spliced into `to`, the layout text it converts to,
15
+ * and the open is unsaved ({@link DocumentEditorOptions.opensDirty}).
16
+ */
17
+ conversion?: {
18
+ from: string;
19
+ to: string;
20
+ };
21
+ /** The file a save overwrites when `source` is a draft of it ({@link DocumentEditorOptions.replaces}). */
22
+ replaces?: string;
23
+ /** The file's path within the package. */
24
+ modelPath?: string;
63
25
  }): DashboardEditor;
@@ -0,0 +1,105 @@
1
+ import { SpliceResult } from './spliceResult';
2
+ /**
3
+ * The editor's state: the document being edited, its history, and saving.
4
+ *
5
+ * Deliberately holds the DOCUMENT and nothing else. Given VALUES — what the
6
+ * preview is running with — are editor state rather than document state and
7
+ * live outside this hook, which is what keeps them out of the undo stack. Undo
8
+ * should take back an edit; it should not rewind the values someone was
9
+ * previewing under.
10
+ *
11
+ * `T` must survive `structuredClone`, and equal documents must `JSON.stringify` equal.
12
+ */
13
+ export interface DocumentEditor<T> {
14
+ document: T;
15
+ /** The document as of the last save (or open). */
16
+ saved: T;
17
+ /** The file as it currently stands, which is what a save patches. */
18
+ source: string;
19
+ canUndo: boolean;
20
+ canRedo: boolean;
21
+ /** Whether saving would change the file: the document differs from what was saved, or it opened that way ({@link DocumentEditorOptions.opensDirty}). */
22
+ dirty: boolean;
23
+ /** Whether the document differs from what was saved, or an undone save left its draft text in no file: work to lose, leaving out an `opensDirty` open that nothing has touched. */
24
+ edited: boolean;
25
+ /** Whether the document opened unsaved and no save has written it since ({@link DocumentEditorOptions.opensDirty}). */
26
+ pendingOpen: boolean;
27
+ /**
28
+ * Why the last save did not happen. The document is untouched when this is
29
+ * set: a refused write keeps the reader's work and reports a defect in the
30
+ * writer, rather than discarding an edit because a tool could not read back
31
+ * what it produced.
32
+ */
33
+ error?: string;
34
+ /** Apply a change. Receives a copy; mutate it freely. */
35
+ update: (change: (draft: T) => void) => void;
36
+ undo: () => void;
37
+ redo: () => void;
38
+ /** Splice the change into the file, or say why it was refused. */
39
+ save: () => Promise<SaveOutcome>;
40
+ /**
41
+ * The file a save would write, without writing it: what View change
42
+ * shows. The failure arm is the writer's refusal, worded for the author.
43
+ */
44
+ preview: () => Promise<{
45
+ ok: true;
46
+ source: string;
47
+ } | {
48
+ ok: false;
49
+ reason: string;
50
+ }>;
51
+ /**
52
+ * Whether the unsaved change is structural, as the caller defines it (false
53
+ * when it defines nothing): the kind of change a save reports as structural.
54
+ */
55
+ structural: boolean;
56
+ /** Whether saving the unsaved change empties the undo stack, as the caller defines it (false when it defines nothing). */
57
+ clearsHistory: boolean;
58
+ /** Whether the last save can still be taken back: true from a save that landed until the next edit, undo, redo or write. */
59
+ canUndoSave: boolean;
60
+ /** What the save `undoSave` would take back did to the file; absent once that offer is withdrawn. */
61
+ lastSave?: LastSave;
62
+ /** Write the file as it stood before the last save, then put the editor back to just before Save: edits unsaved, history intact. */
63
+ undoSave: () => Promise<SaveOutcome>;
64
+ }
65
+ export type SaveOutcome = {
66
+ ok: true;
67
+ } | {
68
+ ok: false;
69
+ reason: string;
70
+ };
71
+ /** The save an undo would take back. */
72
+ export interface LastSave {
73
+ /** The file before the save. */
74
+ before: string;
75
+ /** The file the save wrote. */
76
+ after: string;
77
+ structural: boolean;
78
+ clearsHistory: boolean;
79
+ }
80
+ /** Why a write happens, and the document the written file holds. */
81
+ export interface SaveContext<T> {
82
+ purpose: "save" | "undo";
83
+ document: T;
84
+ }
85
+ /** Persists the patched file; rejecting leaves the editor as it was. */
86
+ export type SaveHandler<T> = (source: string, context: SaveContext<T>) => Promise<void> | void;
87
+ export interface DocumentEditorOptions<T> {
88
+ /** The file as read from storage. */
89
+ source: string;
90
+ /** The document that file produced. */
91
+ document: T;
92
+ /** Persist the patched file. Rejecting leaves the editor dirty. */
93
+ onSave?: SaveHandler<T>;
94
+ /** Patch the document into the file, or say why that was refused. */
95
+ splice: (source: string, document: T) => Promise<SpliceResult>;
96
+ /** The open is itself unsaved: the document is a conversion of the file, so Save is on before any edit and Undo save returns to it. */
97
+ opensDirty?: boolean;
98
+ /** The file the first save overwrites when it is not `source` (a draft opened over the package's file): what Undo save writes back. */
99
+ replaces?: string;
100
+ /** Whether `document` differs structurally from `saved`; omit for never. */
101
+ structural?: (saved: T, document: T) => boolean;
102
+ /** Whether saving `document` over `saved` makes the history unsafe to step back into; the stack is then emptied on save. */
103
+ clearsHistory?: (saved: T, document: T) => boolean;
104
+ }
105
+ export declare function useDocumentEditor<T>(options: DocumentEditorOptions<T>): DocumentEditor<T>;
@@ -0,0 +1,19 @@
1
+ export interface ExitGuardOptions {
2
+ dirty: boolean;
3
+ saving: boolean;
4
+ canSave: boolean;
5
+ /** Resolves once the save has run. */
6
+ save: () => Promise<void> | void;
7
+ onExit: () => void;
8
+ }
9
+ /** "Close" exits at once when clean and asks otherwise; "Save and exit" exits only once its own save settles clean. */
10
+ export declare function useExitGuard({ dirty, saving, canSave, save, onExit, }: ExitGuardOptions): {
11
+ requestExit: () => void;
12
+ dialog: {
13
+ open: boolean;
14
+ canSave: boolean;
15
+ onKeepEditing: () => void;
16
+ onDiscard: () => void;
17
+ onSaveAndExit: () => void;
18
+ };
19
+ };
@@ -1,6 +1,6 @@
1
1
  import { CatalogField } from './catalog';
2
2
  import { BuilderControl, ControlKind, MappingRow } from './controls';
3
- import { DashboardDocument, DashboardTile, LocalGiven } from './document';
3
+ import { DashboardDocument, LocalGiven, QueryTile } from './document';
4
4
  import { Dispatch, SetStateAction } from 'react';
5
5
  type Source = {
6
6
  kind: "existing";
@@ -21,7 +21,7 @@ export declare function useFilterForm({ open, document, control, available, fiel
21
21
  document: DashboardDocument;
22
22
  control: BuilderControl | undefined;
23
23
  available: readonly BuilderControl[];
24
- fieldsFor?: (tile: DashboardTile) => readonly CatalogField[] | undefined;
24
+ fieldsFor?: (tile: QueryTile) => readonly CatalogField[] | undefined;
25
25
  onApply: (given: string, rows: MappingRow[], declare?: LocalGiven) => void;
26
26
  }): {
27
27
  editing: boolean;
@@ -57,7 +57,7 @@ export declare function useFilterForm({ open, document, control, available, fiel
57
57
  setAll: (include: boolean) => void;
58
58
  accepts: (candidate: CatalogField) => boolean;
59
59
  pickField: (next: string) => void;
60
- rowProblems: string[];
60
+ rowProblems: any[];
61
61
  commonProblem: string;
62
62
  canApply: boolean;
63
63
  apply: () => void;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether asking again can succeed after a request failed with `error`: not
3
+ * after a 401, 403 or 404; yes after any other status or no response at all.
4
+ * Reads an axios error's `response.status`, or a `status` on the error itself.
5
+ */
6
+ export declare function canRetryRequest(error: unknown): boolean;
@@ -0,0 +1,58 @@
1
+ import { DocumentLocator, DocumentStorage, DocumentType, Workspace } from '../DocumentStorage/DocumentStorage';
2
+ import { DocumentCreatedEvent } from './events';
3
+ import { NewDocument } from './guards';
4
+ /** How many names are tried before a create gives up: `title`, `title-2`, ... */
5
+ export declare const MAX_SLUG_ATTEMPTS = 20;
6
+ /**
7
+ * Where a create may land, or `undefined` for nowhere. A non-authoritative
8
+ * browser workspace is never a target (`savesTo === "browser"`): a document
9
+ * created there would exist for one reader on one machine and look saved.
10
+ */
11
+ export declare function createRoute(host: {
12
+ authoritative: boolean;
13
+ mutable: boolean;
14
+ /** The host keeps documents and the chosen workspace takes writes. */
15
+ canStore: boolean;
16
+ /** A pinned version takes no package writes. */
17
+ versionId?: string;
18
+ }): "package" | "storage" | undefined;
19
+ export type CreateTarget = {
20
+ route: "package";
21
+ /** Package-relative paths already in the package, as its listing gives them. */
22
+ existing: readonly string[];
23
+ /** A create-only write: no hash, so the server refuses a file that is there. */
24
+ write: (path: string, source: string) => Promise<void>;
25
+ } | {
26
+ route: "storage";
27
+ storage: DocumentStorage;
28
+ workspace: Workspace;
29
+ environmentName: string;
30
+ packageName: string;
31
+ /** Package-relative paths the package already lists; the store may not know them yet. */
32
+ existing?: readonly string[];
33
+ };
34
+ export interface CreatedDocument {
35
+ kind: DocumentType;
36
+ /** Package-relative, e.g. `dashboards/sales.malloy`. */
37
+ path: string;
38
+ /** `sales` for `dashboards/sales.malloy`: what an editor route names. */
39
+ slug: string;
40
+ /** Set on the storage route: the new document's address there. */
41
+ locator?: DocumentLocator;
42
+ }
43
+ export interface CreateDocumentOptions {
44
+ kind: DocumentType;
45
+ document: NewDocument;
46
+ target: CreateTarget;
47
+ onCreated?: (created: CreatedDocument) => void;
48
+ onEvent?: (event: DocumentCreatedEvent) => void;
49
+ }
50
+ /**
51
+ * Write a new dashboard or notebook, never over an existing file, and say where
52
+ * it went. Reads nothing back: the host navigates from what this returns.
53
+ *
54
+ * On the storage route the listing alone cannot be trusted to be current, and
55
+ * `saveDocument` replaces what is there, so each candidate name is read first
56
+ * and used only when the read says the document is absent.
57
+ */
58
+ export declare function createDocument(options: CreateDocumentOptions): Promise<CreatedDocument>;
@@ -0,0 +1,10 @@
1
+ import { DocumentLocator, DocumentType } from '../DocumentStorage';
2
+ export { newDashboardSource, slugFor } from '../DashboardBuilder/newDashboard';
3
+ /** The package-relative file for a slug: always `dashboards/<slug>.malloy` or `notebooks/<slug>.malloy`, the only shapes the server writes. */
4
+ export declare function documentPathFor(kind: DocumentType, slug: string): string;
5
+ /** A title's slug, with a stand-in for a title that has no letters or digits. */
6
+ export declare function slugOrFallback(title: string): string;
7
+ /** The file for a title; `suffix` 1 is the bare slug, 2 and up append `-N`. */
8
+ export declare function documentPathForTitle(kind: DocumentType, title: string, suffix?: number): string;
9
+ /** The storage key for a document's copy; the Console's editors and `createDocument` mint it the same way. */
10
+ export declare const locatorFor: (kind: DocumentType, workspace: string, environmentName: string, packageName: string, path: string) => DocumentLocator;
@@ -0,0 +1,10 @@
1
+ /** A document the host created; `where` names which storage took the write, as on the `*.saved` events. */
2
+ export type DashboardCreatedEvent = {
3
+ type: "dashboard.created";
4
+ where: "package" | "host";
5
+ };
6
+ export type NotebookCreatedEvent = {
7
+ type: "notebook.created";
8
+ where: "package" | "host";
9
+ };
10
+ export type DocumentCreatedEvent = DashboardCreatedEvent | NotebookCreatedEvent;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The sources a model exports. `sources` also lists names the model only
3
+ * imports, and `import { x } from "../model"` cannot reach those; no
4
+ * `modelInfo`, or one that does not parse, offers nothing rather than a
5
+ * choice that would write a file that does not compile.
6
+ */
7
+ export declare function exportedSources(modelInfo: string | undefined): Set<string>;
@@ -0,0 +1,12 @@
1
+ import { DocumentType } from '../DocumentStorage';
2
+ export declare const malloyName: (name: string) => string;
3
+ /** What a new document is made from: a view of a source in a model. */
4
+ export interface NewDocument {
5
+ title: string;
6
+ /** The model that declares the source, relative to the package root. */
7
+ modelPath: string;
8
+ source: string;
9
+ view: string;
10
+ }
11
+ /** Why `input` cannot be written into a new `kind`, or undefined when it can. */
12
+ export declare function newDocumentProblem(kind: DocumentType, input: NewDocument): string | undefined;
@@ -0,0 +1,6 @@
1
+ export { createDocument, createRoute, MAX_SLUG_ATTEMPTS, type CreatedDocument, type CreateDocumentOptions, type CreateTarget, } from './createDocument';
2
+ export { documentPathFor, documentPathForTitle, locatorFor, newDashboardSource, slugFor, slugOrFallback, } from './documentPath';
3
+ export type { DashboardCreatedEvent, DocumentCreatedEvent, NotebookCreatedEvent, } from './events';
4
+ export { newDocumentProblem, type NewDocument } from './guards';
5
+ export { newNotebookSource } from './newNotebook';
6
+ export { useDocumentChoices, type DocumentChoice } from './useDocumentChoices';
@@ -0,0 +1,9 @@
1
+ import { NewDocument } from './guards';
2
+ /**
3
+ * A new notebook file in the layout format a dashboard uses: the givens flag,
4
+ * the artifact tag (a block, a tile per line) listing an intro text tile and one query tile, a named
5
+ * import of the one source it runs (reachable without a whole-file import),
6
+ * the intro block, and one extension of the source (`<source>_tiles`, the
7
+ * builder's naming) holding the picked view as the query tile.
8
+ */
9
+ export declare function newNotebookSource(input: NewDocument): string;
@@ -0,0 +1,32 @@
1
+ export interface DocumentChoice {
2
+ source: string;
3
+ view: string;
4
+ }
5
+ /**
6
+ * What a new dashboard or notebook can start from: model -> the (source, view)
7
+ * pairs it declares. One `getModel` per model under its own key, read only
8
+ * while `enabled` (the dialog is open) and cached after, so opening it costs
9
+ * nothing until it is opened. A model whose lookup errors drops out of
10
+ * `choices` and is named in `failed` (once nothing is loading), so a caller can
11
+ * tell "every lookup failed" from "none exist"; `retry` refetches only those,
12
+ * and `canRetry` says whether any of them could succeed on a second attempt.
13
+ */
14
+ export declare function useDocumentChoices({ environmentName, packageName, versionId, models, enabled, }: {
15
+ environmentName: string;
16
+ packageName: string;
17
+ /** The package version the model list was read at. */
18
+ versionId?: string;
19
+ /** The package's model files, relative to its root. */
20
+ models: readonly string[];
21
+ enabled: boolean;
22
+ }): {
23
+ choices: Map<string, DocumentChoice[]>;
24
+ isLoading: boolean;
25
+ isSuccess: boolean;
26
+ /** Model paths whose lookup errored, in `models` order; empty while loading. */
27
+ failed: string[];
28
+ /** Refetches only the failed lookups. */
29
+ retry: () => void;
30
+ /** Whether a failed lookup could succeed if retried, by {@link canRetryRequest}. */
31
+ canRetry: boolean;
32
+ };
@@ -41,7 +41,8 @@ export declare class DocumentNotFoundError extends Error {
41
41
  export declare const isDocumentNotFound: (error: unknown) => boolean;
42
42
  /**
43
43
  * The kinds of document the SDK authors. A `dashboard` is a
44
- * `dashboards/<slug>.malloy` file; a `notebook` is a `.malloynb`.
44
+ * `dashboards/<slug>.malloy` file; a `notebook` is a
45
+ * `notebooks/<slug>.malloy` file.
45
46
  */
46
47
  export type DocumentType = "dashboard" | "notebook";
47
48
  /** A place documents live, as the backend presents it to a reader. */
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * Wraps an editor: on a screen under 600px it shows a notice with "Edit anyway" first.
4
+ * Decided once at mount, so rotating a phone or resizing a window never swaps the editor out from under an edit.
5
+ */
6
+ export declare function NarrowEditGate({ children }: {
7
+ children: ReactNode;
8
+ }): import("react/jsx-runtime").JSX.Element;
@@ -48,5 +48,5 @@ interface NotebookProps {
48
48
  */
49
49
  onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
50
50
  }
51
- export default function Notebook({ resourceUri, maxResultSize, givens, onGivensChange, onNavigate, onDrillNavigate, }: NotebookProps): import("react/jsx-runtime").JSX.Element;
51
+ export default function Notebook(props: NotebookProps): import("react/jsx-runtime").JSX.Element;
52
52
  export {};
@@ -0,0 +1,33 @@
1
+ import { CreatedDocument, CreateTarget, DocumentCreatedEvent } from '../DocumentCreate';
2
+ import { DocumentType } from '../DocumentStorage/DocumentStorage';
3
+ export interface NewDocumentDialogProps {
4
+ open: boolean;
5
+ /** Which kind the dialog opens on. */
6
+ kind: DocumentType;
7
+ /** Whether the reader may switch to the other kind. Default true. */
8
+ allowKindChange?: boolean;
9
+ environmentName: string;
10
+ packageName: string;
11
+ versionId?: string;
12
+ /** The package's model files, relative to its root, to pick a source from. */
13
+ models: readonly string[];
14
+ /** The host is still listing `models`, so an empty list is not yet "no models". */
15
+ modelsLoading?: boolean;
16
+ /** The host's listing of `models` failed, so an empty list is not "no models". */
17
+ modelsError?: unknown;
18
+ /** Lists the models again; offered when `modelsError` is one a retry can clear. */
19
+ onRetryModels?: () => void;
20
+ /** Where the file is written, and (on the package route) which names are taken. */
21
+ target: CreateTarget;
22
+ /** The line under the title on the storage route, saying where the host keeps the new file. */
23
+ savedAs?: string;
24
+ onClose: () => void;
25
+ onCreated: (created: CreatedDocument) => void;
26
+ onEvent?: (event: DocumentCreatedEvent) => void;
27
+ }
28
+ /**
29
+ * A new dashboard or notebook: pick the model, the view its first tile or
30
+ * query shows, and a title. The file is the one the builder would write, so
31
+ * everything after this is the builder's; the host opens it from `onCreated`.
32
+ */
33
+ export declare function NewDocumentDialog({ open, kind: initialKind, allowKindChange, environmentName, packageName, versionId, models, modelsLoading, modelsError, onRetryModels, target, savedAs, onClose, onCreated, onEvent, }: NewDocumentDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ /** A served notebook opens by slug, like a dashboard; a `.malloynb` opens by path. */
2
3
  interface PackageProps {
3
4
  onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
4
5
  resourceUri: string;