@malloy-publisher/sdk 0.9.7 → 0.9.8

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 (350) hide show
  1. package/README.md +117 -17
  2. package/dist/{RenderedResult-qnpbr4tc.cjs.js → RenderedResult-BrvrMDAP.cjs.js} +1 -1
  3. package/dist/{RenderedResult-CkUS04tl.es.js → RenderedResult-DZj-FnOJ.es.js} +2 -2
  4. package/dist/{ServerProvider-DnLLeXEX.es.js → ServerProvider-B_bPAsu2.es.js} +583 -398
  5. package/dist/ServerProvider-DuEOzwPc.cjs.js +1 -0
  6. package/dist/builder/index.cjs.js +93 -93
  7. package/dist/builder/index.es.js +4630 -4562
  8. package/dist/builder-entry.d.ts +13 -12
  9. package/dist/client/api.d.ts +472 -94
  10. package/dist/client/index.cjs.js +1 -1
  11. package/dist/client/index.es.js +105 -95
  12. package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
  13. package/dist/components/Dashboard/DashboardView.d.ts +1 -3
  14. package/dist/components/Dashboard/index.d.ts +0 -2
  15. package/dist/components/DocumentCreate/createDocument.d.ts +29 -9
  16. package/dist/components/DocumentCreate/documentPath.d.ts +21 -6
  17. package/dist/components/DocumentCreate/guards.d.ts +2 -3
  18. package/dist/components/DocumentCreate/index.d.ts +2 -3
  19. package/dist/components/DocumentCreate/newNotebook.d.ts +14 -5
  20. package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +6 -0
  21. package/dist/components/DocumentStorage/DocumentStorage.d.ts +52 -24
  22. package/dist/components/Loading.d.ts +1 -1
  23. package/dist/components/Package/DataSchemaDialog.d.ts +26 -0
  24. package/dist/components/Package/NewDocumentDialog.d.ts +19 -10
  25. package/dist/components/Package/Package.d.ts +14 -9
  26. package/dist/components/Package/documentLocation.d.ts +66 -23
  27. package/dist/components/Package/index.d.ts +3 -2
  28. package/dist/components/Package/reportQueries.d.ts +8 -0
  29. package/dist/components/Package/useDocumentLocation.d.ts +36 -6
  30. package/dist/components/Package/useDraftLayout.d.ts +20 -0
  31. package/dist/components/Report/CellReport.d.ts +89 -0
  32. package/dist/components/Report/LinearReport.d.ts +18 -0
  33. package/dist/components/Report/Report.d.ts +62 -0
  34. package/dist/components/Report/index.d.ts +2 -0
  35. package/dist/components/Report/telemetry.d.ts +163 -0
  36. package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.d.ts +2 -2
  37. package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.d.ts +2 -2
  38. package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.d.ts +5 -4
  39. package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.d.ts +5 -1
  40. package/dist/components/{DashboardBuilder → ReportBuilder}/EditorSurface.d.ts +10 -7
  41. package/dist/components/{DashboardBuilder/DashboardBuilder.d.ts → ReportBuilder/ReportBuilder.d.ts} +17 -8
  42. package/dist/components/{DashboardBuilder/DashboardEditor.d.ts → ReportBuilder/ReportEditor.d.ts} +41 -14
  43. package/dist/components/ReportBuilder/builderReport.d.ts +14 -0
  44. package/dist/components/{DashboardBuilder → ReportBuilder}/catalog.d.ts +8 -5
  45. package/dist/components/{DashboardBuilder → ReportBuilder}/document.d.ts +3 -4
  46. package/dist/components/{DashboardBuilder → ReportBuilder}/documentSession.d.ts +1 -1
  47. package/dist/components/{DashboardBuilder → ReportBuilder}/imports.d.ts +5 -1
  48. package/dist/components/{DashboardBuilder → ReportBuilder}/malloyTree.d.ts +9 -0
  49. package/dist/components/{DashboardBuilder → ReportBuilder}/newDashboard.d.ts +7 -1
  50. package/dist/components/{DashboardBuilder → ReportBuilder}/readDocument.d.ts +7 -5
  51. package/dist/components/{DashboardBuilder → ReportBuilder}/readForEditor.d.ts +1 -1
  52. package/dist/components/ReportBuilder/reportTag.d.ts +52 -0
  53. package/dist/components/{DashboardBuilder → ReportBuilder}/spliceDocument.d.ts +1 -7
  54. package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.d.ts +2 -2
  55. package/dist/components/{DashboardBuilder → ReportBuilder}/useControlBindings.d.ts +2 -2
  56. package/dist/components/ReportBuilder/useEditorCatalog.d.ts +25 -0
  57. package/dist/components/{DashboardBuilder → ReportBuilder}/useHostCopy.d.ts +5 -3
  58. package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.d.ts +7 -5
  59. package/dist/components/{DashboardBuilder/useDashboardEditor.d.ts → ReportBuilder/useReportEditor.d.ts} +3 -7
  60. package/dist/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.d.ts +6 -4
  61. package/dist/components/{DashboardBuilder → ReportBuilder}/useTileEditing.d.ts +2 -2
  62. package/dist/components/ServerProvider.d.ts +2 -1
  63. package/dist/components/drill/resolveDrill.d.ts +8 -1
  64. package/dist/components/drill/useDrillSelf.d.ts +4 -2
  65. package/dist/components/index.d.ts +2 -1
  66. package/dist/components/{Dashboard → legacy}/Dashboard.d.ts +15 -9
  67. package/dist/components/legacy/MalloynbCells.d.ts +13 -0
  68. package/dist/components/legacy/Notebook.d.ts +15 -0
  69. package/dist/components/{DashboardBuilder → legacy}/NotebookEditor.d.ts +3 -3
  70. package/dist/components/legacy/builderNames.d.ts +10 -0
  71. package/dist/components/legacy/index.d.ts +11 -0
  72. package/dist/components/legacy/kindAdapter.d.ts +11 -0
  73. package/dist/components/legacy/kindTypedDrafts.d.ts +10 -0
  74. package/dist/components/legacy/nameAlias.d.ts +44 -0
  75. package/dist/components/legacy/queryKeys.d.ts +8 -0
  76. package/dist/index.cjs.js +19 -19
  77. package/dist/index.es.js +7984 -7452
  78. package/dist/text/index.es.js +2 -2
  79. package/dist/{text-entry-CA0LZ1xL.es.js → text-entry-72YFLeNk.es.js} +10 -10
  80. package/dist/useCompiledDocument-oocN5cGE.cjs.js +141 -0
  81. package/dist/{useCompiledDocument-Bf72Ob5v.es.js → useCompiledDocument-x0B2RAH3.es.js} +4593 -4395
  82. package/package.json +2 -2
  83. package/src/builder-entry.ts +32 -24
  84. package/src/components/Dashboard/DashboardTile.tsx +17 -0
  85. package/src/components/Dashboard/DashboardView.spec.tsx +0 -21
  86. package/src/components/Dashboard/DashboardView.tsx +8 -24
  87. package/src/components/Dashboard/dropValueUrlTags.spec.ts +1 -4
  88. package/src/components/Dashboard/index.ts +0 -2
  89. package/src/components/DocumentCreate/createDocument.spec.ts +346 -53
  90. package/src/components/DocumentCreate/createDocument.ts +143 -63
  91. package/src/components/DocumentCreate/documentPath.ts +41 -12
  92. package/src/components/DocumentCreate/guards.ts +7 -15
  93. package/src/components/DocumentCreate/index.ts +3 -7
  94. package/src/components/DocumentCreate/newNotebook.spec.ts +113 -43
  95. package/src/components/DocumentCreate/newNotebook.ts +32 -10
  96. package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +130 -28
  97. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +78 -40
  98. package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +426 -0
  99. package/src/components/DocumentStorage/DocumentStorage.ts +57 -24
  100. package/src/components/Home/AddEnvironmentDialog.tsx +1 -1
  101. package/src/components/Home/Home.tsx +1 -1
  102. package/src/components/Loading.tsx +1 -1
  103. package/src/components/Model/SourcesExplorer.tsx +1 -1
  104. package/src/components/Notebook/NotebookCell.tsx +6 -5
  105. package/src/components/Notebook/cellKind.spec.ts +15 -7
  106. package/src/components/Package/DataSchemaDialog.spec.tsx +85 -0
  107. package/src/components/Package/DataSchemaDialog.tsx +367 -0
  108. package/src/components/Package/NewDocumentDialog.spec.tsx +145 -88
  109. package/src/components/Package/NewDocumentDialog.tsx +93 -48
  110. package/src/components/Package/Package.artifacts.spec.tsx +79 -60
  111. package/src/components/Package/Package.create.spec.tsx +126 -112
  112. package/src/components/Package/Package.notebooks.spec.tsx +46 -27
  113. package/src/components/Package/Package.spec.tsx +43 -30
  114. package/src/components/Package/Package.tsx +173 -292
  115. package/src/components/Package/documentLocation.spec.ts +145 -50
  116. package/src/components/Package/documentLocation.ts +118 -39
  117. package/src/components/Package/index.ts +12 -3
  118. package/src/components/Package/reportQueries.ts +25 -0
  119. package/src/components/Package/useDocumentLocation.spec.ts +58 -0
  120. package/src/components/Package/useDocumentLocation.ts +90 -32
  121. package/src/components/Package/useDraftLayout.spec.tsx +143 -0
  122. package/src/components/Package/useDraftLayout.ts +81 -0
  123. package/src/components/Prose.spec.tsx +3 -3
  124. package/src/components/RenderedResult/RenderedResult.tsx +1 -1
  125. package/src/components/Report/CellReport.spec.tsx +155 -0
  126. package/src/components/{Notebook/Notebook.tsx → Report/CellReport.tsx} +178 -220
  127. package/src/components/Report/LinearReport.tsx +71 -0
  128. package/src/components/Report/Report.spec.tsx +238 -0
  129. package/src/components/Report/Report.telemetry.spec.tsx +292 -0
  130. package/src/components/Report/Report.tsx +277 -0
  131. package/src/components/Report/index.ts +12 -0
  132. package/src/components/Report/telemetry.spec.ts +90 -0
  133. package/src/components/Report/telemetry.ts +250 -0
  134. package/src/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.tsx +5 -5
  135. package/src/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.tsx +2 -2
  136. package/src/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.tsx +6 -7
  137. package/src/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.tsx +33 -0
  138. package/src/components/{DashboardBuilder → ReportBuilder}/DrillDialog.tsx +2 -2
  139. package/src/components/{DashboardBuilder → ReportBuilder}/EditorSurface.tsx +67 -107
  140. package/src/components/{DashboardBuilder → ReportBuilder}/FilterDialog.tsx +3 -4
  141. package/src/components/{DashboardBuilder/DashboardBuilder.charts.spec.tsx → ReportBuilder/ReportBuilder.charts.spec.tsx} +4 -4
  142. package/src/components/{DashboardBuilder/DashboardBuilder.exit.spec.tsx → ReportBuilder/ReportBuilder.exit.spec.tsx} +5 -5
  143. package/src/components/{DashboardBuilder/DashboardBuilder.inline.spec.tsx → ReportBuilder/ReportBuilder.inline.spec.tsx} +4 -4
  144. package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +145 -0
  145. package/src/components/{DashboardBuilder/DashboardBuilder.notebook.spec.tsx → ReportBuilder/ReportBuilder.notebook.spec.tsx} +22 -21
  146. package/src/components/{DashboardBuilder/DashboardBuilder.openDraft.spec.tsx → ReportBuilder/ReportBuilder.openDraft.spec.tsx} +3 -3
  147. package/src/components/{DashboardBuilder/DashboardBuilder.sources.spec.tsx → ReportBuilder/ReportBuilder.sources.spec.tsx} +19 -8
  148. package/src/components/{DashboardBuilder/DashboardBuilder.spec.tsx → ReportBuilder/ReportBuilder.spec.tsx} +34 -34
  149. package/src/components/{DashboardBuilder/DashboardBuilder.textTiles.spec.tsx → ReportBuilder/ReportBuilder.textTiles.spec.tsx} +5 -5
  150. package/src/components/{DashboardBuilder/DashboardBuilder.tsx → ReportBuilder/ReportBuilder.tsx} +46 -21
  151. package/src/components/{DashboardBuilder/DashboardEditor.authoritative.spec.tsx → ReportBuilder/ReportEditor.authoritative.spec.tsx} +28 -20
  152. package/src/components/{DashboardBuilder/DashboardEditor.emptyStart.spec.tsx → ReportBuilder/ReportEditor.emptyStart.spec.tsx} +19 -11
  153. package/src/components/{DashboardBuilder/DashboardEditor.filterTag.spec.tsx → ReportBuilder/ReportEditor.filterTag.spec.tsx} +7 -7
  154. package/src/components/{DashboardBuilder/DashboardEditor.notebook.spec.tsx → ReportBuilder/ReportEditor.notebook.spec.tsx} +70 -49
  155. package/src/components/{DashboardBuilder/DashboardEditor.package.spec.tsx → ReportBuilder/ReportEditor.package.spec.tsx} +52 -8
  156. package/src/components/{DashboardBuilder/DashboardEditor.resourceUri.spec.tsx → ReportBuilder/ReportEditor.resourceUri.spec.tsx} +50 -18
  157. package/src/components/{DashboardBuilder/DashboardEditor.spec.tsx → ReportBuilder/ReportEditor.spec.tsx} +65 -20
  158. package/src/components/{DashboardBuilder/DashboardEditor.textSource.spec.tsx → ReportBuilder/ReportEditor.textSource.spec.tsx} +6 -6
  159. package/src/components/{DashboardBuilder/DashboardEditor.tsx → ReportBuilder/ReportEditor.tsx} +92 -35
  160. package/src/components/{DashboardBuilder → ReportBuilder}/addTile.compile.spec.ts +1 -3
  161. package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.spec.ts +1 -0
  162. package/src/components/{DashboardBuilder → ReportBuilder}/artifactBlock.spec.ts +21 -29
  163. package/src/components/ReportBuilder/builderReport.ts +53 -0
  164. package/src/components/{DashboardBuilder → ReportBuilder}/catalog.spec.ts +28 -10
  165. package/src/components/{DashboardBuilder → ReportBuilder}/catalog.ts +17 -10
  166. package/src/components/{DashboardBuilder → ReportBuilder}/controls.spec.ts +1 -0
  167. package/src/components/{DashboardBuilder → ReportBuilder}/document.ts +4 -7
  168. package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.spec.ts +5 -5
  169. package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.ts +1 -1
  170. package/src/components/{DashboardBuilder → ReportBuilder}/imports.spec.ts +6 -2
  171. package/src/components/{DashboardBuilder → ReportBuilder}/imports.ts +8 -4
  172. package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.chart.spec.ts +1 -1
  173. package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.convert.spec.ts +9 -13
  174. package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.read.spec.ts +15 -15
  175. package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.ts +7 -2
  176. package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.ts +25 -0
  177. package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.spec.ts +12 -4
  178. package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.ts +11 -24
  179. package/src/components/{DashboardBuilder → ReportBuilder}/preview.spec.ts +1 -0
  180. package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.spec.ts +64 -36
  181. package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.ts +33 -32
  182. package/src/components/ReportBuilder/readForEditor.spec.ts +96 -0
  183. package/src/components/{DashboardBuilder → ReportBuilder}/readForEditor.ts +3 -11
  184. package/src/components/ReportBuilder/reportTag.ts +108 -0
  185. package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.imports.spec.ts +28 -1
  186. package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.spec.ts +32 -3
  187. package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.ts +37 -60
  188. package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.spec.ts +3 -3
  189. package/src/components/{DashboardBuilder → ReportBuilder}/testing/artifactTagParity.json +2 -2
  190. package/src/components/ReportBuilder/testing/drillResolution.json +279 -0
  191. package/src/components/ReportBuilder/testing/reportLayoutParity.json +125 -0
  192. package/src/components/{DashboardBuilder → ReportBuilder}/textTiles.spec.ts +66 -143
  193. package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.ts +2 -2
  194. package/src/components/{DashboardBuilder → ReportBuilder}/useControlBindings.ts +2 -2
  195. package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +156 -0
  196. package/src/components/ReportBuilder/useEditorCatalog.ts +119 -0
  197. package/src/components/{DashboardBuilder → ReportBuilder}/useHostCopy.ts +7 -5
  198. package/src/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.ts +56 -35
  199. package/src/components/{DashboardBuilder/useDashboardEditor.spec.ts → ReportBuilder/useReportEditor.spec.ts} +6 -6
  200. package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts} +6 -17
  201. package/src/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.ts +36 -35
  202. package/src/components/{DashboardBuilder → ReportBuilder}/useTileEditing.ts +2 -2
  203. package/src/components/ServerProvider.tsx +2 -0
  204. package/src/components/drill/resolveDrill.ts +9 -2
  205. package/src/components/drill/useDrill.tsx +1 -0
  206. package/src/components/drill/useDrillSelf.spec.tsx +60 -7
  207. package/src/components/drill/useDrillSelf.ts +29 -12
  208. package/src/components/index.ts +2 -1
  209. package/src/components/{Dashboard → legacy}/Dashboard.spec.tsx +1 -1
  210. package/src/components/{Dashboard → legacy}/Dashboard.tsx +40 -28
  211. package/src/components/legacy/MalloynbCells.tsx +88 -0
  212. package/src/components/{Notebook → legacy}/Notebook.served.spec.tsx +17 -13
  213. package/src/components/{Notebook → legacy}/Notebook.spec.tsx +24 -20
  214. package/src/components/legacy/Notebook.tsx +44 -0
  215. package/src/components/{DashboardBuilder → legacy}/NotebookEditor.tsx +7 -4
  216. package/src/components/legacy/builderNames.ts +25 -0
  217. package/src/components/legacy/index.ts +20 -0
  218. package/src/components/legacy/kindAdapter.ts +19 -0
  219. package/src/components/legacy/kindTypedDrafts.ts +34 -0
  220. package/src/components/legacy/nameAlias.spec.ts +124 -0
  221. package/src/components/legacy/nameAlias.ts +95 -0
  222. package/src/components/legacy/queryKeys.ts +26 -0
  223. package/src/hooks/useGivensState.spec.ts +9 -9
  224. package/src/mainEntry.spec.ts +1 -1
  225. package/src/textEntry.spec.ts +9 -9
  226. package/src/utils/formatting.spec.ts +5 -5
  227. package/src/utils/parsing.spec.ts +1 -1
  228. package/src/utils/parsing.ts +1 -1
  229. package/dist/ServerProvider-Gj-im5VD.cjs.js +0 -1
  230. package/dist/components/Dashboard/telemetry.d.ts +0 -73
  231. package/dist/components/DashboardBuilder/builderReport.d.ts +0 -13
  232. package/dist/components/DashboardBuilder/telemetry.d.ts +0 -43
  233. package/dist/components/DocumentCreate/events.d.ts +0 -10
  234. package/dist/components/Notebook/Notebook.d.ts +0 -52
  235. package/dist/components/Notebook/index.d.ts +0 -1
  236. package/dist/useCompiledDocument-tBejqZ7s.cjs.js +0 -142
  237. package/src/components/Dashboard/telemetry.ts +0 -75
  238. package/src/components/DashboardBuilder/builderReport.ts +0 -74
  239. package/src/components/DashboardBuilder/readForEditor.spec.ts +0 -80
  240. package/src/components/DashboardBuilder/telemetry.ts +0 -47
  241. package/src/components/DashboardBuilder/testing/documentKindRule.json +0 -40
  242. package/src/components/DocumentCreate/events.ts +0 -15
  243. package/src/components/Notebook/index.ts +0 -4
  244. /package/dist/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.d.ts +0 -0
  245. /package/dist/components/{DashboardBuilder → ReportBuilder}/ChartPicker.d.ts +0 -0
  246. /package/dist/components/{DashboardBuilder → ReportBuilder}/DrillDialog.d.ts +0 -0
  247. /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterDialog.d.ts +0 -0
  248. /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterStrip.d.ts +0 -0
  249. /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.d.ts +0 -0
  250. /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineText.d.ts +0 -0
  251. /package/dist/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.d.ts +0 -0
  252. /package/dist/components/{DashboardBuilder → ReportBuilder}/TextTileBody.d.ts +0 -0
  253. /package/dist/components/{DashboardBuilder → ReportBuilder}/TileFrame.d.ts +0 -0
  254. /package/dist/components/{DashboardBuilder → ReportBuilder}/TileMenu.d.ts +0 -0
  255. /package/dist/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.d.ts +0 -0
  256. /package/dist/components/{DashboardBuilder → ReportBuilder}/annotationText.d.ts +0 -0
  257. /package/dist/components/{DashboardBuilder → ReportBuilder}/changedTile.d.ts +0 -0
  258. /package/dist/components/{DashboardBuilder → ReportBuilder}/chartLine.d.ts +0 -0
  259. /package/dist/components/{DashboardBuilder → ReportBuilder}/controls.d.ts +0 -0
  260. /package/dist/components/{DashboardBuilder → ReportBuilder}/inlineEdit.d.ts +0 -0
  261. /package/dist/components/{DashboardBuilder → ReportBuilder}/layout.d.ts +0 -0
  262. /package/dist/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.d.ts +0 -0
  263. /package/dist/components/{DashboardBuilder → ReportBuilder}/loadMalloy.d.ts +0 -0
  264. /package/dist/components/{DashboardBuilder → ReportBuilder}/openDraft.d.ts +0 -0
  265. /package/dist/components/{DashboardBuilder → ReportBuilder}/preview.d.ts +0 -0
  266. /package/dist/components/{DashboardBuilder → ReportBuilder}/sortable.d.ts +0 -0
  267. /package/dist/components/{DashboardBuilder → ReportBuilder}/spliceResult.d.ts +0 -0
  268. /package/dist/components/{DashboardBuilder → ReportBuilder}/tagParse.d.ts +0 -0
  269. /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.d.ts +0 -0
  270. /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/inline.d.ts +0 -0
  271. /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/resize.d.ts +0 -0
  272. /package/dist/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.d.ts +0 -0
  273. /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.d.ts +0 -0
  274. /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.d.ts +0 -0
  275. /package/dist/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.d.ts +0 -0
  276. /package/dist/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.d.ts +0 -0
  277. /package/dist/components/{DashboardBuilder → ReportBuilder}/useDraft.d.ts +0 -0
  278. /package/dist/components/{DashboardBuilder → ReportBuilder}/useExitGuard.d.ts +0 -0
  279. /package/dist/components/{DashboardBuilder → ReportBuilder}/useFilterForm.d.ts +0 -0
  280. /package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.d.ts +0 -0
  281. /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileReorder.d.ts +0 -0
  282. /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileResize.d.ts +0 -0
  283. /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.spec.tsx +0 -0
  284. /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.tsx +0 -0
  285. /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.render.spec.tsx +0 -0
  286. /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.spec.ts +0 -0
  287. /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.tsx +0 -0
  288. /package/src/components/{DashboardBuilder → ReportBuilder}/FilterStrip.tsx +0 -0
  289. /package/src/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.tsx +0 -0
  290. /package/src/components/{DashboardBuilder → ReportBuilder}/InlineText.tsx +0 -0
  291. /package/src/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.tsx +0 -0
  292. /package/src/components/{DashboardBuilder → ReportBuilder}/TextTileBody.tsx +0 -0
  293. /package/src/components/{DashboardBuilder → ReportBuilder}/TileFrame.tsx +0 -0
  294. /package/src/components/{DashboardBuilder → ReportBuilder}/TileMenu.tsx +0 -0
  295. /package/src/components/{DashboardBuilder → ReportBuilder}/__test__/inventory.ts +0 -0
  296. /package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.ts +0 -0
  297. /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.spec.ts +0 -0
  298. /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.ts +0 -0
  299. /package/src/components/{DashboardBuilder → ReportBuilder}/artifactTagParity.spec.ts +0 -0
  300. /package/src/components/{DashboardBuilder → ReportBuilder}/catalog.aggregate.spec.ts +0 -0
  301. /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.spec.ts +0 -0
  302. /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.ts +0 -0
  303. /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.spec.ts +0 -0
  304. /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.ts +0 -0
  305. /package/src/components/{DashboardBuilder → ReportBuilder}/controls.ts +0 -0
  306. /package/src/components/{DashboardBuilder → ReportBuilder}/emptyStart.spec.ts +0 -0
  307. /package/src/components/{DashboardBuilder → ReportBuilder}/inlineEdit.tsx +0 -0
  308. /package/src/components/{DashboardBuilder → ReportBuilder}/invariants.spec.ts +0 -0
  309. /package/src/components/{DashboardBuilder → ReportBuilder}/keepRowStructure.spec.ts +0 -0
  310. /package/src/components/{DashboardBuilder → ReportBuilder}/layout.ts +0 -0
  311. /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.spec.ts +0 -0
  312. /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.ts +0 -0
  313. /package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.spec.ts +0 -0
  314. /package/src/components/{DashboardBuilder → ReportBuilder}/moveIntoGap.spec.ts +0 -0
  315. /package/src/components/{DashboardBuilder → ReportBuilder}/openDraft.ts +0 -0
  316. /package/src/components/{DashboardBuilder → ReportBuilder}/preview.shapes.spec.ts +0 -0
  317. /package/src/components/{DashboardBuilder → ReportBuilder}/preview.ts +0 -0
  318. /package/src/components/{DashboardBuilder → ReportBuilder}/scannerShapes.spec.ts +0 -0
  319. /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.spec.ts +0 -0
  320. /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.tsx +0 -0
  321. /package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.chart.spec.ts +0 -0
  322. /package/src/components/{DashboardBuilder → ReportBuilder}/spliceResult.ts +0 -0
  323. /package/src/components/{DashboardBuilder → ReportBuilder}/statementExtent.spec.ts +0 -0
  324. /package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.ts +0 -0
  325. /package/src/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.ts +0 -0
  326. /package/src/components/{DashboardBuilder → ReportBuilder}/testing/inline.ts +0 -0
  327. /package/src/components/{DashboardBuilder → ReportBuilder}/testing/resize.ts +0 -0
  328. /package/src/components/{DashboardBuilder → ReportBuilder}/testing/urlRenderTags.json +0 -0
  329. /package/src/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.ts +0 -0
  330. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.spec.ts +0 -0
  331. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.ts +0 -0
  332. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.overlay.spec.tsx +0 -0
  333. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.spec.tsx +0 -0
  334. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.ts +0 -0
  335. /package/src/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.ts +0 -0
  336. /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.spec.ts +0 -0
  337. /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.ts +0 -0
  338. /package/src/components/{DashboardBuilder → ReportBuilder}/useDraft.ts +0 -0
  339. /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.spec.ts +0 -0
  340. /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.ts +0 -0
  341. /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.existing.spec.tsx +0 -0
  342. /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.spec.tsx +0 -0
  343. /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.ts +0 -0
  344. /package/src/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.ts +0 -0
  345. /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.spec.tsx +0 -0
  346. /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.ts +0 -0
  347. /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.spec.tsx +0 -0
  348. /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.ts +0 -0
  349. /package/src/components/{DashboardBuilder → ReportBuilder}/withGaps.spec.ts +0 -0
  350. /package/src/components/{Notebook → legacy}/Notebook.layout.spec.tsx +0 -0
@@ -2,28 +2,27 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
4
  import "@malloydata/malloy-explorer/styles.css";
5
- import { Box, Stack, Typography } from "@mui/material";
5
+ import { Stack, Typography } from "@mui/material";
6
6
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
7
- import { planRun } from "./runPlan";
8
- import { RawNotebook } from "../../client";
9
- import { GivenValue } from "../../hooks/givenValue";
7
+ import type { NotebookCell as RawCell, RawNotebook } from "../../client";
8
+ import type { GivenValue } from "../../hooks/givenValue";
10
9
  import { useDocumentControls } from "../../hooks/useDocumentControls";
11
10
  import { useModelGivens } from "../../hooks/useModelGivens";
12
11
  import { GIVEN_SETTLE_MS } from "../../hooks/useSettled";
13
- import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
14
12
  import { parseResourceUri } from "../../utils/formatting";
15
- import { ApiErrorDisplay } from "../ApiErrorDisplay";
13
+ import { ApiErrorDisplay, type ApiError } from "../ApiErrorDisplay";
16
14
  import type { NavigationClick } from "../click_helper";
17
- import { DashboardProse, DashboardView } from "../Dashboard/DashboardView";
18
15
  import type { DrillNavigation } from "../drill";
19
16
  import { GivensPanel } from "../given";
20
17
  import { givensToParams, givensToRequest } from "../given/paramCodec";
21
18
  import { Loading, LOADING_COPY } from "../Loading";
19
+ import { cellRuns } from "../Notebook/cellKind";
20
+ import { NotebookCell } from "../Notebook/NotebookCell";
21
+ import { planRun } from "../Notebook/runPlan";
22
+ import type { EnhancedNotebookCell } from "../Notebook/types";
22
23
  import { useServer } from "../ServerProvider";
24
+ import { failureCategory, useReportEvents } from "./telemetry";
23
25
  import { CleanNotebookContainer, CleanNotebookSection } from "../styles";
24
- import { cellRuns } from "./cellKind";
25
- import { NotebookCell } from "./NotebookCell";
26
- import { EnhancedNotebookCell } from "./types";
27
26
 
28
27
  // Maximum number of concurrent cell executions to avoid overwhelming the server
29
28
  const MAX_CONCURRENT = 4;
@@ -45,13 +44,28 @@ function cellErrorMessage(error: unknown): string {
45
44
  return "The server did not say why.";
46
45
  }
47
46
 
48
- interface NotebookProps {
47
+ /** What one cell's run is handed: the cell, its index, the values to run it with, and the signal that cancels it. */
48
+ interface CellRun {
49
+ cell: RawCell;
50
+ index: number;
51
+ givens: ReadonlyMap<string, GivenValue>;
52
+ declaredTypes: ReadonlyMap<string, string | undefined>;
53
+ signal: AbortSignal;
54
+ }
55
+
56
+ /** Runs one cell. Stable across renders: a new runner re-runs every cell. */
57
+ export type CellRunner = (
58
+ run: CellRun,
59
+ ) => Promise<{ result?: string; newSources?: string[] }>;
60
+
61
+ export interface CellReportProps {
62
+ /** `publisher://…/models/<path>`: the report, and the model its cells run against. */
49
63
  resourceUri: string;
50
64
  maxResultSize?: number;
51
65
  /**
52
66
  * Parameter values from the host, typically its URL query parameters: the
53
- * same contract `Dashboard` takes, so a link into a filtered notebook works
54
- * the way a link into a filtered dashboard does.
67
+ * same contract `Report` takes, so a link into a filtered report works the
68
+ * way a link into a filtered grid does.
55
69
  */
56
70
  givens?: Record<string, string>;
57
71
  /**
@@ -62,130 +76,69 @@ interface NotebookProps {
62
76
  * That is every committed change. Under `## autorun=false` a change is
63
77
  * committed on Apply, so reports are batched; otherwise every change is
64
78
  * committed and typing in a text control reports per keystroke. It does NOT
65
- * run per keystroke: a changed value waits
66
- * `GIVEN_SETTLE_MS` before anything is dispatched, so a burst of typing
67
- * produces one run. A run that does start supersedes and aborts the one
68
- * before it. The REPORTS are still per keystroke, so a host doing something
69
- * expensive per call should debounce.
79
+ * run per keystroke: a changed value waits `GIVEN_SETTLE_MS` before
80
+ * anything is dispatched, so a burst of typing produces one run. A run that
81
+ * does start supersedes and aborts the one before it. The REPORTS are still
82
+ * per keystroke, so a host doing something expensive per call should
83
+ * debounce.
70
84
  *
71
- * `managed` names every given this notebook declares, set or not. A host
85
+ * `managed` names every given this report declares, set or not. A host
72
86
  * writing to a shared query string needs it: `givens` alone says which
73
- * parameters to write but not which to *remove*, and a host that guesses by
74
- * removing everything it did not just receive deletes the unrelated
75
- * parameters it has no business touching.
87
+ * parameters to write but not which to *remove*.
76
88
  */
77
89
  onGivensChange?: (
78
90
  givens: Record<string, string>,
79
91
  managed: readonly string[],
80
92
  ) => void;
81
93
  /**
82
- * Optional SPA navigation handler for links inside the notebook. When
83
- * omitted, in-notebook links fall back to plain absolute anchors, so no
84
- * react-router context is required to render a notebook.
94
+ * Optional SPA navigation handler for links inside the cells. When omitted,
95
+ * links fall back to plain absolute anchors, so no react-router context is
96
+ * required to render one.
85
97
  *
86
- * It does NOT carry drill. A `# drill { to=self }` filters this notebook
98
+ * It does NOT carry drill. A `# drill { to=self }` filters this report
87
99
  * through `given:` state and needs no handler at all, and a drill naming a
88
- * dashboard goes through {@link onDrillNavigate}, which takes a destination
100
+ * report goes through {@link onDrillNavigate}, which takes a destination
89
101
  * rather than a URL.
90
102
  */
91
103
  onNavigate?: (to: string, event?: NavigationClick) => void;
92
104
  /**
93
- * Opens a `# drill { to=<dashboard> }` from a cell, seeded with the clicked
94
- * value. Omitted on a host with no dashboard route, which leaves those
105
+ * Opens a `# drill { to=<report> }` from a cell, seeded with the clicked
106
+ * value. Omitted on a host with no report route, which leaves those
95
107
  * destinations inert AND unmarked rather than painting a dead link.
96
108
  */
97
109
  onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
98
110
  }
99
111
 
100
- /** The raw notebook, one cache entry per URI however many components ask. */
101
- function useNotebookQuery(resourceUri: string) {
102
- const { apiClients } = useServer();
103
- const {
104
- environmentName,
105
- packageName,
106
- versionId,
107
- modelPath: notebookPath,
108
- } = parseResourceUri(resourceUri);
109
- return useQueryWithApiError<RawNotebook>({
110
- queryKey: [resourceUri],
111
- queryFn: async () => {
112
- const response = await apiClients.notebooks.getNotebook(
113
- environmentName,
114
- packageName,
115
- notebookPath,
116
- versionId,
117
- );
118
- return response.data;
119
- },
120
- });
121
- }
122
-
123
- // Requires PackageProvider
124
- export default function Notebook(props: NotebookProps) {
125
- const { data: notebook } = useNotebookQuery(props.resourceUri);
126
- // A notebook written as a tile layout renders as a one-column dashboard.
127
- if (notebook?.dashboard) {
128
- const { environmentName, packageName, versionId, modelPath } =
129
- parseResourceUri(props.resourceUri);
130
- const { title, description } = notebook.dashboard;
131
- return (
132
- <CleanNotebookContainer>
133
- <CleanNotebookSection>
134
- {/* chrome="none" drops the view's own header, so the prose is drawn here. */}
135
- {(title || description) && (
136
- <Box sx={{ mb: 2 }}>
137
- <DashboardProse
138
- // A notebook's text tiles have no card; its description matches them.
139
- chrome="none"
140
- title={title ?? ""}
141
- {...(description ? { description } : {})}
142
- />
143
- </Box>
144
- )}
145
- <DashboardView
146
- manifest={notebook.dashboard}
147
- environmentName={environmentName}
148
- packageName={packageName}
149
- versionId={versionId}
150
- documentName={modelPath}
151
- givens={props.givens}
152
- onGivensChange={props.onGivensChange}
153
- onNavigate={props.onDrillNavigate}
154
- maxResultSize={props.maxResultSize}
155
- chrome="none"
156
- // A cell notebook's control panel, not a dashboard's bar.
157
- controlsLayout="panel"
158
- />
159
- </CleanNotebookSection>
160
- </CleanNotebookContainer>
161
- );
162
- }
163
- return <CellNotebook {...props} />;
164
- }
165
-
166
- function CellNotebook({
112
+ /**
113
+ * Cells run one by one, the engine behind a report written as `run:` cells.
114
+ * Takes the cells (undefined while they load, `error` when they could not be
115
+ * read) and the runner that executes one; what reads the cells and what runs
116
+ * them is the caller's.
117
+ */
118
+ export function CellRunnerView({
167
119
  resourceUri,
168
120
  maxResultSize = 0,
169
121
  givens,
170
122
  onGivensChange,
171
123
  onNavigate,
172
124
  onDrillNavigate,
173
- }: NotebookProps) {
174
- const { apiClients } = useServer();
125
+ notebook,
126
+ error,
127
+ runCell,
128
+ }: CellReportProps & {
129
+ notebook: RawNotebook | undefined;
130
+ /** Why the cells could not be read; the view says so in place of them. */
131
+ error?: ApiError | null;
132
+ runCell: CellRunner;
133
+ }) {
175
134
  const {
176
135
  environmentName,
177
136
  packageName,
178
137
  versionId,
179
138
  modelPath: notebookPath,
180
139
  } = parseResourceUri(resourceUri);
181
-
182
- // Fetch the raw notebook cells
183
- const {
184
- data: notebook,
185
- isSuccess,
186
- isError,
187
- error,
188
- } = useNotebookQuery(resourceUri);
140
+ const isSuccess = notebook !== undefined;
141
+ const isError = !isSuccess && !!error;
189
142
 
190
143
  // State to store executed cells with results
191
144
  const [enhancedCells, setEnhancedCells] = useState<EnhancedNotebookCell[]>(
@@ -196,19 +149,21 @@ function CellNotebook({
196
149
  // `isExecuting`, which covers only a run actually in flight.
197
150
  const [runScheduled, setRunScheduled] = useState(false);
198
151
  // The document the last run belonged to, for abandoning its requests when
199
- // the reader moves to another notebook without this component unmounting.
152
+ // the reader moves to another report without this component unmounting.
200
153
  const lastDocumentRef = useRef<string | undefined>(undefined);
201
154
  const [executionError, setExecutionError] = useState<Error | null>(null);
202
155
 
203
156
  // Model-level `given:` declarations, and the state behind their controls:
204
- // the same hook the dashboard uses, so both surfaces get URL-addressable
157
+ // the same hook a grid uses, so both layouts get URL-addressable
205
158
  // parameters, Apply batching and `to=self` drill from one implementation.
206
159
  const declaredGivens = useModelGivens(notebook);
207
160
  // A file-level `## autorun=false` arrives as `RawNotebook.autorun`, the same
208
- // field with the same default a dashboard's `# artifact { autorun=false }`
209
- // produces. Batching matters more here than on a dashboard: one control
210
- // change re-runs every cell in the document.
161
+ // field with the same default a grid's `## artifact { autorun=false }`
162
+ // produces. Batching matters more here than on a grid: one control change
163
+ // re-runs every cell in the document.
211
164
  const autorun = notebook?.autorun !== false;
165
+ // Set by `Report`; silent under the deprecated `Notebook`, which shares this view.
166
+ const events = useReportEvents();
212
167
  const controls = useDocumentControls({
213
168
  specs: declaredGivens,
214
169
  loaded: isSuccess,
@@ -220,7 +175,7 @@ function CellNotebook({
220
175
  autorun,
221
176
  environmentName,
222
177
  packageName,
223
- // A notebook's model path is the notebook itself: `suggest` queries run
178
+ // The report's model path is the report itself: `suggest` queries run
224
179
  // against the same model the cells do.
225
180
  modelPath: notebookPath,
226
181
  versionId,
@@ -233,13 +188,8 @@ function CellNotebook({
233
188
  onSelf: onDrillSelf,
234
189
  } = controls;
235
190
 
236
- /**
237
- * The `givens` query param for the notebook-cell GET: the same map the
238
- * dashboard's POST body carries, JSON-encoded because this endpoint takes it
239
- * in the URL. Built by the shared codec so a given is encoded identically
240
- * whichever surface runs it.
241
- */
242
- const buildGivens = useCallback(
191
+ /** The run key's encoding of a set of values: the request body the cells are sent, so values that encode identically do not re-run. */
192
+ const encodeGivens = useCallback(
243
193
  (values: Map<string, GivenValue>): string | undefined => {
244
194
  const request = givensToRequest(values, declaredTypes);
245
195
  return Object.keys(request).length > 0
@@ -249,7 +199,7 @@ function CellNotebook({
249
199
  [declaredTypes],
250
200
  );
251
201
 
252
- // For a cell's "Data Sources" dialog: the notebook's current values, so
202
+ // For a cell's "Data Sources" dialog: the report's current values, so
253
203
  // exploring from a cell starts from what the reader is looking at rather
254
204
  // than the model's bare defaults.
255
205
  const cellStartingGivens = useMemo(
@@ -276,32 +226,22 @@ function CellNotebook({
276
226
  >(undefined);
277
227
 
278
228
  // Cancel whatever is in flight when this component goes away, so navigating
279
- // off a twelve-cell notebook does not leave twelve requests to complete and be
229
+ // off a twelve-cell report does not leave twelve requests to complete and be
280
230
  // thrown away.
281
231
  //
282
- // Its OWN effect, with an empty dependency list, and that is the whole point:
283
- // as the run effect's cleanup this ran on every dependency change instead. The
284
- // host echoes each reported parameter back, which gives `applied` a new
285
- // identity with identical content, so the cleanup fired and aborted the run
286
- // the control change had just started, while the run effect's `runKey` guard
287
- // saw an unchanged key and refused to start a replacement. Every cell was left
288
- // blank, with no result, no error and no spinner, until a reload. Measured on
289
- // `governed-analytics/orders.malloynb`: 4 rendered results before a control
290
- // change, 0 after.
232
+ // Its OWN effect, with an empty dependency list, not the run effect's
233
+ // cleanup: the host echoes each reported parameter back, giving `applied` a
234
+ // new identity with identical content. A cleanup on that change would abort
235
+ // the run the control change just started, while the `runKey` guard sees an
236
+ // unchanged key and starts no replacement, leaving every cell blank.
291
237
  useEffect(
292
238
  () => () => {
293
239
  inFlightRef.current?.abort();
294
240
  // Forget which run was last started, so a component that comes back
295
- // runs again instead of trusting a key whose run was just cancelled.
296
- // The case it is reasoned from, and NOT one I could reproduce: React's
297
- // StrictMode mounts, cleans up, and mounts again in development, and
298
- // refs survive that. A first mount that already had the notebook
299
- // cached would start a run, this cleanup would abort it, and the
300
- // second mount would see an unchanged `runKey` and decline to start a
301
- // replacement. I could not get a browser into that state, so treat the
302
- // reset as belt-and-braces rather than a measured fix. It is right on
303
- // its own terms either way: a key that says "this run happened" must
304
- // not outlive the run being cancelled.
241
+ // runs again instead of trusting a key whose run was just cancelled
242
+ // (React's StrictMode mounts, cleans up, and mounts again, and refs
243
+ // survive that). A key that says "this run happened" must not outlive
244
+ // the run being cancelled.
305
245
  lastRunRef.current = null;
306
246
  clearTimeout(pendingRunRef.current?.timer);
307
247
  pendingRunRef.current = undefined;
@@ -315,33 +255,22 @@ function CellNotebook({
315
255
  const runId = ++runIdRef.current;
316
256
 
317
257
  // Cancel the run this one supersedes rather than just ignoring its
318
- // results. Discarding results alone keeps the requests in flight, so
319
- // three quick control changes on a twelve-cell notebook put three full
320
- // runs on the server and use the answers from one. `origin/main`
321
- // refused to start a second run at all, which was the wrong trade,
322
- // it dropped the newest values, but it did bound the load, and
323
- // nothing replaced that bound.
258
+ // results: discarding results alone keeps the requests in flight, so
259
+ // three quick control changes on a twelve-cell report put three full
260
+ // runs on the server and use the answers from one.
324
261
  inFlightRef.current?.abort();
325
262
  const controller = new AbortController();
326
263
  inFlightRef.current = controller;
327
264
 
328
- // Rebuilt from the notebook being run, never carried over from the
329
- // previous render's cells. Reusing them kept the OLD document's
330
- // `text` and `type` while the new document's results were written in
331
- // on top, so navigating between two notebooks rendered one's prose
332
- // with the other's charts, and a shorter second notebook left the
333
- // first one's trailing cells on screen. Nothing worth preserving
334
- // survived that branch anyway: `result` and `error` were cleared, and
335
- // `newSources` is re-derived from the raw cell below.
265
+ // Rebuilt from the report being run, never carried over from the
266
+ // previous render's cells, which would keep the OLD document's text
267
+ // under the new document's results.
336
268
  setEnhancedCells(notebook.notebookCells.map((cell) => ({ ...cell })));
337
269
 
338
270
  setIsExecuting(true);
339
271
  setExecutionError(null);
340
272
 
341
- const givensParam = buildGivens(givensToApply);
342
-
343
273
  try {
344
- // Build execution tasks for code cells
345
274
  const executionTasks: Array<() => Promise<void>> = [];
346
275
 
347
276
  for (let i = 0; i < notebook.notebookCells.length; i++) {
@@ -350,38 +279,26 @@ function CellNotebook({
350
279
  // Prose and definitions have nothing to run.
351
280
  if (!cellRuns(rawCell)) continue;
352
281
 
353
- // Capture cell index for closure
354
282
  const cellIndex = i;
355
283
 
356
284
  const executeCell = async () => {
357
285
  try {
358
- // `filterParams` and `bypassFilters` go over as undefined:
359
- // the `#(filter)` panel this component used to render is
360
- // gone, replaced by `given:`. The server still enforces a
361
- // `required` filter, so a model that has one now fails
362
- // here: visibly, via `error` below, rather than as the
363
- // blank cell it used to be. See RELEASE_NOTES.
364
- const response =
365
- await apiClients.notebooks.executeNotebookCell(
366
- environmentName,
367
- packageName,
368
- notebookPath,
369
- cellIndex,
370
- versionId,
371
- undefined,
372
- undefined,
373
- givensParam,
374
- { signal: controller.signal },
375
- );
286
+ const executedCell = await runCell({
287
+ cell: rawCell,
288
+ index: cellIndex,
289
+ givens: givensToApply,
290
+ declaredTypes,
291
+ signal: controller.signal,
292
+ });
376
293
 
377
294
  if (runIdRef.current !== runId) return;
378
295
 
379
- const executedCell = response.data;
380
296
  const result = executedCell.result;
297
+ // A `.malloy` report's cells carry their sources on the
298
+ // manifest; a run adds none.
381
299
  const newSources =
382
300
  rawCell.newSources || executedCell.newSources;
383
301
 
384
- // Update state incrementally
385
302
  setEnhancedCells((prev) => {
386
303
  const next = [...prev];
387
304
  if (!next[cellIndex]) {
@@ -402,10 +319,18 @@ function CellNotebook({
402
319
  runIdRef.current !== runId
403
320
  )
404
321
  return;
405
- console.error(
406
- `Error executing cell ${cellIndex}:`,
407
- cellError,
408
- );
322
+ // The cell shows its error; the host hears of it, or
323
+ // without one the console does, so it is never lost.
324
+ events.emit({
325
+ type: "report.query_failed",
326
+ tile: cellIndex,
327
+ category: failureCategory(cellError),
328
+ });
329
+ if (!events.listening)
330
+ console.error(
331
+ `Error executing cell ${cellIndex}:`,
332
+ cellError,
333
+ );
409
334
  const message = cellErrorMessage(cellError);
410
335
  setEnhancedCells((prev) => {
411
336
  const next = [...prev];
@@ -438,11 +363,15 @@ function CellNotebook({
438
363
  }
439
364
  }
440
365
 
441
- // Wait for remaining tasks to complete
442
366
  await Promise.all(executing);
443
367
  } catch (error) {
444
368
  if (controller.signal.aborted || runIdRef.current !== runId) return;
445
- console.error("Error executing notebook cells:", error);
369
+ events.emit({
370
+ type: "report.query_failed",
371
+ category: failureCategory(error),
372
+ });
373
+ if (!events.listening)
374
+ console.error("Error executing notebook cells:", error);
446
375
  setExecutionError(error as Error);
447
376
  } finally {
448
377
  if (runIdRef.current === runId) {
@@ -451,34 +380,22 @@ function CellNotebook({
451
380
  }
452
381
  }
453
382
  },
454
- [
455
- isSuccess,
456
- notebook,
457
- buildGivens,
458
- environmentName,
459
- packageName,
460
- notebookPath,
461
- versionId,
462
- apiClients.notebooks,
463
- ],
383
+ [isSuccess, notebook, declaredTypes, runCell, events],
464
384
  );
465
385
 
466
386
  // Run the cells on load, and again whenever the applied parameters change.
467
387
  // Applied, not draft: under `## autorun=false` the cells wait for Apply.
468
388
  //
469
389
  // One effect covers both, keyed on exactly what would go over the wire plus
470
- // which notebook it is. Keying on the encoded givens means a change that
390
+ // which report it is. Keying on the encoded givens means a change that
471
391
  // encodes identically does not re-run, and a link carrying parameters runs
472
392
  // once with them rather than running bare and running again when they land.
473
393
  // A run already in flight is superseded rather than waited on, which the
474
394
  // generation guard in `executeCells` makes safe.
475
395
  //
476
- // The notebook's own identity is part of that key. Its content can change
477
- // under an open tab: a package reload, and react-query hands over a new
478
- // object only when the content actually differs, so identity is exactly the
479
- // "has this document changed" signal. Keying on `resourceUri` alone silently
480
- // dropped that: a reloaded notebook kept rendering the previous run's
481
- // results forever, because the URI and the givens were unchanged.
396
+ // The cells' own identity is part of that key: a package reload hands over
397
+ // a new object only when the content actually differs, so identity is
398
+ // exactly the "has this document changed" signal.
482
399
  const notebookGenRef = useRef(0);
483
400
  const seenNotebookRef = useRef<RawNotebook | undefined>(undefined);
484
401
  if (seenNotebookRef.current !== notebook) {
@@ -489,13 +406,11 @@ function CellNotebook({
489
406
 
490
407
  useEffect(() => {
491
408
  const documentKey = `${resourceUri}|${notebookGen}`;
492
- const runKey = `${documentKey}|${buildGivens(applied) ?? ""}`;
409
+ const runKey = `${documentKey}|${encodeGivens(applied) ?? ""}`;
493
410
 
494
- // Abandon the previous notebook's requests when the document changes.
411
+ // Abandon the previous report's requests when the document changes.
495
412
  // The abort-on-unmount effect does not cover this: navigating from one
496
- // notebook to another REUSES this component, so nothing unmounts and a
497
- // twelve-cell notebook left twelve requests running against a document
498
- // the reader had already left.
413
+ // report to another REUSES this component, so nothing unmounts.
499
414
  if (
500
415
  lastDocumentRef.current !== undefined &&
501
416
  lastDocumentRef.current !== documentKey
@@ -531,11 +446,8 @@ function CellNotebook({
531
446
  start();
532
447
  return;
533
448
  }
534
- // Flagged while the settle timer runs, so the cells say a run is coming.
535
- // Without it the window was invisible: `isExecuting` is false until the
536
- // timer fires, so a changed control sat above the PREVIOUS values with
537
- // nothing on screen to say they were stale, and a reader who kept typing
538
- // kept extending the window.
449
+ // Flagged while the settle timer runs, so the cells say a run is coming;
450
+ // `isExecuting` is false until the timer fires.
539
451
  setRunScheduled(true);
540
452
  pendingRunRef.current = {
541
453
  key: runKey,
@@ -547,13 +459,13 @@ function CellNotebook({
547
459
  notebookGen,
548
460
  resourceUri,
549
461
  applied,
550
- buildGivens,
462
+ encodeGivens,
551
463
  executeCells,
552
464
  ]);
553
465
 
554
466
  const shownCells =
555
467
  enhancedCells.length > 0 ? enhancedCells : notebook?.notebookCells || [];
556
- // A served notebook can open with definition cells; a .malloynb keeps the icon on its first cell.
468
+ // A served report can open with definition cells; a .malloynb keeps the icon on its first cell.
557
469
  const copyLinkIndex =
558
470
  notebook?.format === "malloy"
559
471
  ? shownCells.findIndex((cell) => cell.type === "markdown")
@@ -566,12 +478,10 @@ function CellNotebook({
566
478
  {/* Parameters panel: the controls for `given:` declarations */}
567
479
  <GivensPanel {...controls.panel} />
568
480
 
569
- {/* Loading State */}
570
481
  {!isSuccess && !isError && (
571
- <Loading text={LOADING_COPY.opening("notebook")} />
482
+ <Loading text={LOADING_COPY.opening("report")} />
572
483
  )}
573
484
 
574
- {/* Notebook Cells */}
575
485
  {isSuccess &&
576
486
  shownCells.map((cell, index) => (
577
487
  <NotebookCell
@@ -597,17 +507,16 @@ function CellNotebook({
597
507
  />
598
508
  ))}
599
509
 
600
- {/* Error States */}
601
- {isError && error.status === 404 && (
510
+ {isError && error?.status === 404 && (
602
511
  <Typography variant="body2" sx={{ color: "text.secondary" }}>
603
512
  <code>{`${environmentName} > ${packageName} > ${notebookPath}`}</code>{" "}
604
513
  not found.
605
514
  </Typography>
606
515
  )}
607
516
 
608
- {isError && error.status !== 404 && (
517
+ {isError && error?.status !== 404 && (
609
518
  <ApiErrorDisplay
610
- error={error}
519
+ error={error as ApiError}
611
520
  context={`${environmentName} > ${packageName} > ${notebookPath}`}
612
521
  />
613
522
  )}
@@ -627,3 +536,52 @@ function CellNotebook({
627
536
  </CleanNotebookContainer>
628
537
  );
629
538
  }
539
+
540
+ /**
541
+ * A `.malloy` report written as `run:` cells, whose cells the caller already
542
+ * holds (`Report` reads them off `GET …/reports/{path}`). Each runs through
543
+ * the governed query endpoint the grid tiles use
544
+ * (`POST …/models/{path}/query`, the report's path as the model and the cell's
545
+ * text as the query), which holds a cell to the same surface, `#(authorize)`
546
+ * and row-level gates a tile is held to.
547
+ */
548
+ export function CellReport({
549
+ notebook: held,
550
+ ...props
551
+ }: CellReportProps & { notebook: RawNotebook }) {
552
+ const { apiClients } = useServer();
553
+ const { environmentName, packageName, versionId, modelPath } =
554
+ parseResourceUri(props.resourceUri);
555
+ // Handed over from the first render after mount, not on it, so the
556
+ // controls see the document ARRIVE as they do when it is fetched: that
557
+ // arrival is what reports the file's starting values to the host's URL
558
+ // (`useGivensState` seeds its record from the first render).
559
+ const [mounted, setMounted] = useState(false);
560
+ useEffect(() => setMounted(true), []);
561
+ const runCell = useCallback<CellRunner>(
562
+ async ({ cell, givens, declaredTypes, signal }) => ({
563
+ result: (
564
+ await apiClients.models.executeQueryModel(
565
+ environmentName,
566
+ packageName,
567
+ modelPath,
568
+ {
569
+ query: cell.text,
570
+ givens: givensToRequest(givens, declaredTypes),
571
+ versionId,
572
+ },
573
+ undefined,
574
+ { signal },
575
+ )
576
+ ).data.result,
577
+ }),
578
+ [apiClients.models, environmentName, packageName, modelPath, versionId],
579
+ );
580
+ return (
581
+ <CellRunnerView
582
+ {...props}
583
+ notebook={mounted ? held : undefined}
584
+ runCell={runCell}
585
+ />
586
+ );
587
+ }