@malloy-publisher/sdk 0.9.7 → 0.9.9

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 (353) hide show
  1. package/README.md +117 -17
  2. package/dist/{RenderedResult-CkUS04tl.es.js → RenderedResult-BHuJpdSn.es.js} +2 -2
  3. package/dist/{RenderedResult-qnpbr4tc.cjs.js → RenderedResult-Bw7EQc42.cjs.js} +1 -1
  4. package/dist/ServerProvider-B0dUY8be.cjs.js +1 -0
  5. package/dist/{ServerProvider-DnLLeXEX.es.js → ServerProvider-CQy4jVYK.es.js} +1602 -1074
  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 +893 -104
  10. package/dist/client/index.cjs.js +1 -1
  11. package/dist/client/index.es.js +125 -104
  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/ContentTypeIcon.d.ts +3 -3
  24. package/dist/components/Package/DataSchemaDialog.d.ts +26 -0
  25. package/dist/components/Package/NewDocumentDialog.d.ts +19 -10
  26. package/dist/components/Package/Package.d.ts +14 -9
  27. package/dist/components/Package/documentLocation.d.ts +66 -23
  28. package/dist/components/Package/index.d.ts +3 -2
  29. package/dist/components/Package/reportQueries.d.ts +8 -0
  30. package/dist/components/Package/useDocumentLocation.d.ts +36 -6
  31. package/dist/components/Package/useDraftLayout.d.ts +20 -0
  32. package/dist/components/Report/CellReport.d.ts +89 -0
  33. package/dist/components/Report/LinearReport.d.ts +18 -0
  34. package/dist/components/Report/Report.d.ts +62 -0
  35. package/dist/components/Report/index.d.ts +2 -0
  36. package/dist/components/Report/telemetry.d.ts +163 -0
  37. package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.d.ts +2 -2
  38. package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.d.ts +2 -2
  39. package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.d.ts +5 -4
  40. package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.d.ts +5 -1
  41. package/dist/components/{DashboardBuilder → ReportBuilder}/EditorSurface.d.ts +10 -7
  42. package/dist/components/{DashboardBuilder/DashboardBuilder.d.ts → ReportBuilder/ReportBuilder.d.ts} +17 -8
  43. package/dist/components/{DashboardBuilder/DashboardEditor.d.ts → ReportBuilder/ReportEditor.d.ts} +41 -14
  44. package/dist/components/ReportBuilder/builderReport.d.ts +14 -0
  45. package/dist/components/{DashboardBuilder → ReportBuilder}/catalog.d.ts +8 -5
  46. package/dist/components/{DashboardBuilder → ReportBuilder}/document.d.ts +3 -4
  47. package/dist/components/{DashboardBuilder → ReportBuilder}/documentSession.d.ts +1 -1
  48. package/dist/components/{DashboardBuilder → ReportBuilder}/imports.d.ts +5 -1
  49. package/dist/components/{DashboardBuilder → ReportBuilder}/malloyTree.d.ts +9 -0
  50. package/dist/components/{DashboardBuilder → ReportBuilder}/newDashboard.d.ts +7 -1
  51. package/dist/components/{DashboardBuilder → ReportBuilder}/readDocument.d.ts +7 -5
  52. package/dist/components/{DashboardBuilder → ReportBuilder}/readForEditor.d.ts +1 -1
  53. package/dist/components/ReportBuilder/reportTag.d.ts +52 -0
  54. package/dist/components/{DashboardBuilder → ReportBuilder}/spliceDocument.d.ts +1 -7
  55. package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.d.ts +2 -2
  56. package/dist/components/{DashboardBuilder → ReportBuilder}/useControlBindings.d.ts +2 -2
  57. package/dist/components/ReportBuilder/useEditorCatalog.d.ts +25 -0
  58. package/dist/components/{DashboardBuilder → ReportBuilder}/useHostCopy.d.ts +5 -3
  59. package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.d.ts +7 -5
  60. package/dist/components/{DashboardBuilder/useDashboardEditor.d.ts → ReportBuilder/useReportEditor.d.ts} +3 -7
  61. package/dist/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.d.ts +6 -4
  62. package/dist/components/{DashboardBuilder → ReportBuilder}/useTileEditing.d.ts +2 -2
  63. package/dist/components/ServerProvider.d.ts +2 -1
  64. package/dist/components/drill/resolveDrill.d.ts +8 -1
  65. package/dist/components/drill/useDrillSelf.d.ts +4 -2
  66. package/dist/components/index.d.ts +2 -1
  67. package/dist/components/{Dashboard → legacy}/Dashboard.d.ts +15 -9
  68. package/dist/components/legacy/MalloynbCells.d.ts +13 -0
  69. package/dist/components/legacy/Notebook.d.ts +15 -0
  70. package/dist/components/{DashboardBuilder → legacy}/NotebookEditor.d.ts +3 -3
  71. package/dist/components/legacy/builderNames.d.ts +10 -0
  72. package/dist/components/legacy/index.d.ts +11 -0
  73. package/dist/components/legacy/kindAdapter.d.ts +11 -0
  74. package/dist/components/legacy/kindTypedDrafts.d.ts +10 -0
  75. package/dist/components/legacy/nameAlias.d.ts +44 -0
  76. package/dist/components/legacy/queryKeys.d.ts +8 -0
  77. package/dist/index.cjs.js +19 -19
  78. package/dist/index.es.js +8216 -7635
  79. package/dist/text/index.es.js +2 -2
  80. package/dist/{text-entry-CA0LZ1xL.es.js → text-entry-72YFLeNk.es.js} +10 -10
  81. package/dist/{useCompiledDocument-Bf72Ob5v.es.js → useCompiledDocument-1dgF5CC9.es.js} +4593 -4395
  82. package/dist/useCompiledDocument-BKyRnXmA.cjs.js +141 -0
  83. package/package.json +2 -2
  84. package/src/builder-entry.ts +32 -24
  85. package/src/components/Dashboard/DashboardTile.tsx +17 -0
  86. package/src/components/Dashboard/DashboardView.spec.tsx +0 -21
  87. package/src/components/Dashboard/DashboardView.tsx +8 -24
  88. package/src/components/Dashboard/dropValueUrlTags.spec.ts +1 -4
  89. package/src/components/Dashboard/index.ts +0 -2
  90. package/src/components/DocumentCreate/createDocument.spec.ts +346 -53
  91. package/src/components/DocumentCreate/createDocument.ts +143 -63
  92. package/src/components/DocumentCreate/documentPath.ts +41 -12
  93. package/src/components/DocumentCreate/guards.ts +7 -15
  94. package/src/components/DocumentCreate/index.ts +3 -7
  95. package/src/components/DocumentCreate/newNotebook.spec.ts +113 -43
  96. package/src/components/DocumentCreate/newNotebook.ts +32 -10
  97. package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +130 -28
  98. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +78 -40
  99. package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +426 -0
  100. package/src/components/DocumentStorage/DocumentStorage.ts +57 -24
  101. package/src/components/Home/AddEnvironmentDialog.tsx +1 -1
  102. package/src/components/Home/Home.tsx +1 -1
  103. package/src/components/Loading.tsx +1 -1
  104. package/src/components/Model/SourcesExplorer.tsx +1 -1
  105. package/src/components/Notebook/NotebookCell.tsx +6 -5
  106. package/src/components/Notebook/cellKind.spec.ts +15 -7
  107. package/src/components/Package/ContentTypeIcon.tsx +16 -3
  108. package/src/components/Package/DataSchemaDialog.spec.tsx +85 -0
  109. package/src/components/Package/DataSchemaDialog.tsx +367 -0
  110. package/src/components/Package/NewDocumentDialog.spec.tsx +145 -88
  111. package/src/components/Package/NewDocumentDialog.tsx +93 -48
  112. package/src/components/Package/Package.agents.spec.tsx +76 -0
  113. package/src/components/Package/Package.artifacts.spec.tsx +79 -60
  114. package/src/components/Package/Package.create.spec.tsx +126 -112
  115. package/src/components/Package/Package.notebooks.spec.tsx +46 -27
  116. package/src/components/Package/Package.spec.tsx +43 -30
  117. package/src/components/Package/Package.tsx +217 -293
  118. package/src/components/Package/documentLocation.spec.ts +145 -50
  119. package/src/components/Package/documentLocation.ts +118 -39
  120. package/src/components/Package/index.ts +12 -3
  121. package/src/components/Package/reportQueries.ts +25 -0
  122. package/src/components/Package/useDocumentLocation.spec.ts +58 -0
  123. package/src/components/Package/useDocumentLocation.ts +90 -32
  124. package/src/components/Package/useDraftLayout.spec.tsx +143 -0
  125. package/src/components/Package/useDraftLayout.ts +81 -0
  126. package/src/components/Prose.spec.tsx +3 -3
  127. package/src/components/RenderedResult/RenderedResult.tsx +1 -1
  128. package/src/components/Report/CellReport.spec.tsx +155 -0
  129. package/src/components/{Notebook/Notebook.tsx → Report/CellReport.tsx} +178 -220
  130. package/src/components/Report/LinearReport.tsx +71 -0
  131. package/src/components/Report/Report.spec.tsx +238 -0
  132. package/src/components/Report/Report.telemetry.spec.tsx +292 -0
  133. package/src/components/Report/Report.tsx +277 -0
  134. package/src/components/Report/index.ts +12 -0
  135. package/src/components/Report/telemetry.spec.ts +90 -0
  136. package/src/components/Report/telemetry.ts +250 -0
  137. package/src/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.tsx +5 -5
  138. package/src/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.tsx +2 -2
  139. package/src/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.tsx +6 -7
  140. package/src/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.tsx +33 -0
  141. package/src/components/{DashboardBuilder → ReportBuilder}/DrillDialog.tsx +2 -2
  142. package/src/components/{DashboardBuilder → ReportBuilder}/EditorSurface.tsx +67 -107
  143. package/src/components/{DashboardBuilder → ReportBuilder}/FilterDialog.tsx +3 -4
  144. package/src/components/{DashboardBuilder/DashboardBuilder.charts.spec.tsx → ReportBuilder/ReportBuilder.charts.spec.tsx} +4 -4
  145. package/src/components/{DashboardBuilder/DashboardBuilder.exit.spec.tsx → ReportBuilder/ReportBuilder.exit.spec.tsx} +5 -5
  146. package/src/components/{DashboardBuilder/DashboardBuilder.inline.spec.tsx → ReportBuilder/ReportBuilder.inline.spec.tsx} +4 -4
  147. package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +145 -0
  148. package/src/components/{DashboardBuilder/DashboardBuilder.notebook.spec.tsx → ReportBuilder/ReportBuilder.notebook.spec.tsx} +22 -21
  149. package/src/components/{DashboardBuilder/DashboardBuilder.openDraft.spec.tsx → ReportBuilder/ReportBuilder.openDraft.spec.tsx} +3 -3
  150. package/src/components/{DashboardBuilder/DashboardBuilder.sources.spec.tsx → ReportBuilder/ReportBuilder.sources.spec.tsx} +19 -8
  151. package/src/components/{DashboardBuilder/DashboardBuilder.spec.tsx → ReportBuilder/ReportBuilder.spec.tsx} +34 -34
  152. package/src/components/{DashboardBuilder/DashboardBuilder.textTiles.spec.tsx → ReportBuilder/ReportBuilder.textTiles.spec.tsx} +5 -5
  153. package/src/components/{DashboardBuilder/DashboardBuilder.tsx → ReportBuilder/ReportBuilder.tsx} +46 -21
  154. package/src/components/{DashboardBuilder/DashboardEditor.authoritative.spec.tsx → ReportBuilder/ReportEditor.authoritative.spec.tsx} +28 -20
  155. package/src/components/{DashboardBuilder/DashboardEditor.emptyStart.spec.tsx → ReportBuilder/ReportEditor.emptyStart.spec.tsx} +19 -11
  156. package/src/components/{DashboardBuilder/DashboardEditor.filterTag.spec.tsx → ReportBuilder/ReportEditor.filterTag.spec.tsx} +7 -7
  157. package/src/components/{DashboardBuilder/DashboardEditor.notebook.spec.tsx → ReportBuilder/ReportEditor.notebook.spec.tsx} +70 -49
  158. package/src/components/{DashboardBuilder/DashboardEditor.package.spec.tsx → ReportBuilder/ReportEditor.package.spec.tsx} +52 -8
  159. package/src/components/{DashboardBuilder/DashboardEditor.resourceUri.spec.tsx → ReportBuilder/ReportEditor.resourceUri.spec.tsx} +50 -18
  160. package/src/components/{DashboardBuilder/DashboardEditor.spec.tsx → ReportBuilder/ReportEditor.spec.tsx} +65 -20
  161. package/src/components/{DashboardBuilder/DashboardEditor.textSource.spec.tsx → ReportBuilder/ReportEditor.textSource.spec.tsx} +6 -6
  162. package/src/components/{DashboardBuilder/DashboardEditor.tsx → ReportBuilder/ReportEditor.tsx} +92 -35
  163. package/src/components/{DashboardBuilder → ReportBuilder}/addTile.compile.spec.ts +1 -3
  164. package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.spec.ts +1 -0
  165. package/src/components/{DashboardBuilder → ReportBuilder}/artifactBlock.spec.ts +21 -29
  166. package/src/components/ReportBuilder/builderReport.ts +53 -0
  167. package/src/components/{DashboardBuilder → ReportBuilder}/catalog.spec.ts +28 -10
  168. package/src/components/{DashboardBuilder → ReportBuilder}/catalog.ts +17 -10
  169. package/src/components/{DashboardBuilder → ReportBuilder}/controls.spec.ts +1 -0
  170. package/src/components/{DashboardBuilder → ReportBuilder}/document.ts +4 -7
  171. package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.spec.ts +5 -5
  172. package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.ts +1 -1
  173. package/src/components/{DashboardBuilder → ReportBuilder}/imports.spec.ts +6 -2
  174. package/src/components/{DashboardBuilder → ReportBuilder}/imports.ts +8 -4
  175. package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.chart.spec.ts +1 -1
  176. package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.convert.spec.ts +9 -13
  177. package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.read.spec.ts +15 -15
  178. package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.ts +7 -2
  179. package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.ts +25 -0
  180. package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.spec.ts +12 -4
  181. package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.ts +11 -24
  182. package/src/components/{DashboardBuilder → ReportBuilder}/preview.spec.ts +1 -0
  183. package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.spec.ts +64 -36
  184. package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.ts +33 -32
  185. package/src/components/ReportBuilder/readForEditor.spec.ts +96 -0
  186. package/src/components/{DashboardBuilder → ReportBuilder}/readForEditor.ts +3 -11
  187. package/src/components/ReportBuilder/reportTag.ts +108 -0
  188. package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.imports.spec.ts +28 -1
  189. package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.spec.ts +32 -3
  190. package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.ts +37 -60
  191. package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.spec.ts +3 -3
  192. package/src/components/{DashboardBuilder → ReportBuilder}/testing/artifactTagParity.json +2 -2
  193. package/src/components/ReportBuilder/testing/drillResolution.json +279 -0
  194. package/src/components/ReportBuilder/testing/reportLayoutParity.json +125 -0
  195. package/src/components/{DashboardBuilder → ReportBuilder}/textTiles.spec.ts +66 -143
  196. package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.ts +2 -2
  197. package/src/components/{DashboardBuilder → ReportBuilder}/useControlBindings.ts +2 -2
  198. package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +156 -0
  199. package/src/components/ReportBuilder/useEditorCatalog.ts +119 -0
  200. package/src/components/{DashboardBuilder → ReportBuilder}/useHostCopy.ts +7 -5
  201. package/src/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.ts +56 -35
  202. package/src/components/{DashboardBuilder/useDashboardEditor.spec.ts → ReportBuilder/useReportEditor.spec.ts} +6 -6
  203. package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts} +6 -17
  204. package/src/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.ts +36 -35
  205. package/src/components/{DashboardBuilder → ReportBuilder}/useTileEditing.ts +2 -2
  206. package/src/components/ServerProvider.tsx +2 -0
  207. package/src/components/drill/resolveDrill.ts +9 -2
  208. package/src/components/drill/useDrill.tsx +1 -0
  209. package/src/components/drill/useDrillSelf.spec.tsx +60 -7
  210. package/src/components/drill/useDrillSelf.ts +29 -12
  211. package/src/components/index.ts +2 -1
  212. package/src/components/{Dashboard → legacy}/Dashboard.spec.tsx +1 -1
  213. package/src/components/{Dashboard → legacy}/Dashboard.tsx +40 -28
  214. package/src/components/legacy/MalloynbCells.tsx +88 -0
  215. package/src/components/{Notebook → legacy}/Notebook.served.spec.tsx +17 -13
  216. package/src/components/{Notebook → legacy}/Notebook.spec.tsx +24 -20
  217. package/src/components/legacy/Notebook.tsx +44 -0
  218. package/src/components/{DashboardBuilder → legacy}/NotebookEditor.tsx +7 -4
  219. package/src/components/legacy/builderNames.ts +25 -0
  220. package/src/components/legacy/index.ts +20 -0
  221. package/src/components/legacy/kindAdapter.ts +19 -0
  222. package/src/components/legacy/kindTypedDrafts.ts +34 -0
  223. package/src/components/legacy/nameAlias.spec.ts +124 -0
  224. package/src/components/legacy/nameAlias.ts +95 -0
  225. package/src/components/legacy/queryKeys.ts +26 -0
  226. package/src/hooks/useGivensState.spec.ts +9 -9
  227. package/src/mainEntry.spec.ts +1 -1
  228. package/src/textEntry.spec.ts +9 -9
  229. package/src/utils/formatting.spec.ts +5 -5
  230. package/src/utils/parsing.spec.ts +1 -1
  231. package/src/utils/parsing.ts +1 -1
  232. package/dist/ServerProvider-Gj-im5VD.cjs.js +0 -1
  233. package/dist/components/Dashboard/telemetry.d.ts +0 -73
  234. package/dist/components/DashboardBuilder/builderReport.d.ts +0 -13
  235. package/dist/components/DashboardBuilder/telemetry.d.ts +0 -43
  236. package/dist/components/DocumentCreate/events.d.ts +0 -10
  237. package/dist/components/Notebook/Notebook.d.ts +0 -52
  238. package/dist/components/Notebook/index.d.ts +0 -1
  239. package/dist/useCompiledDocument-tBejqZ7s.cjs.js +0 -142
  240. package/src/components/Dashboard/telemetry.ts +0 -75
  241. package/src/components/DashboardBuilder/builderReport.ts +0 -74
  242. package/src/components/DashboardBuilder/readForEditor.spec.ts +0 -80
  243. package/src/components/DashboardBuilder/telemetry.ts +0 -47
  244. package/src/components/DashboardBuilder/testing/documentKindRule.json +0 -40
  245. package/src/components/DocumentCreate/events.ts +0 -15
  246. package/src/components/Notebook/index.ts +0 -4
  247. /package/dist/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.d.ts +0 -0
  248. /package/dist/components/{DashboardBuilder → ReportBuilder}/ChartPicker.d.ts +0 -0
  249. /package/dist/components/{DashboardBuilder → ReportBuilder}/DrillDialog.d.ts +0 -0
  250. /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterDialog.d.ts +0 -0
  251. /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterStrip.d.ts +0 -0
  252. /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.d.ts +0 -0
  253. /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineText.d.ts +0 -0
  254. /package/dist/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.d.ts +0 -0
  255. /package/dist/components/{DashboardBuilder → ReportBuilder}/TextTileBody.d.ts +0 -0
  256. /package/dist/components/{DashboardBuilder → ReportBuilder}/TileFrame.d.ts +0 -0
  257. /package/dist/components/{DashboardBuilder → ReportBuilder}/TileMenu.d.ts +0 -0
  258. /package/dist/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.d.ts +0 -0
  259. /package/dist/components/{DashboardBuilder → ReportBuilder}/annotationText.d.ts +0 -0
  260. /package/dist/components/{DashboardBuilder → ReportBuilder}/changedTile.d.ts +0 -0
  261. /package/dist/components/{DashboardBuilder → ReportBuilder}/chartLine.d.ts +0 -0
  262. /package/dist/components/{DashboardBuilder → ReportBuilder}/controls.d.ts +0 -0
  263. /package/dist/components/{DashboardBuilder → ReportBuilder}/inlineEdit.d.ts +0 -0
  264. /package/dist/components/{DashboardBuilder → ReportBuilder}/layout.d.ts +0 -0
  265. /package/dist/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.d.ts +0 -0
  266. /package/dist/components/{DashboardBuilder → ReportBuilder}/loadMalloy.d.ts +0 -0
  267. /package/dist/components/{DashboardBuilder → ReportBuilder}/openDraft.d.ts +0 -0
  268. /package/dist/components/{DashboardBuilder → ReportBuilder}/preview.d.ts +0 -0
  269. /package/dist/components/{DashboardBuilder → ReportBuilder}/sortable.d.ts +0 -0
  270. /package/dist/components/{DashboardBuilder → ReportBuilder}/spliceResult.d.ts +0 -0
  271. /package/dist/components/{DashboardBuilder → ReportBuilder}/tagParse.d.ts +0 -0
  272. /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.d.ts +0 -0
  273. /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/inline.d.ts +0 -0
  274. /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/resize.d.ts +0 -0
  275. /package/dist/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.d.ts +0 -0
  276. /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.d.ts +0 -0
  277. /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.d.ts +0 -0
  278. /package/dist/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.d.ts +0 -0
  279. /package/dist/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.d.ts +0 -0
  280. /package/dist/components/{DashboardBuilder → ReportBuilder}/useDraft.d.ts +0 -0
  281. /package/dist/components/{DashboardBuilder → ReportBuilder}/useExitGuard.d.ts +0 -0
  282. /package/dist/components/{DashboardBuilder → ReportBuilder}/useFilterForm.d.ts +0 -0
  283. /package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.d.ts +0 -0
  284. /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileReorder.d.ts +0 -0
  285. /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileResize.d.ts +0 -0
  286. /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.spec.tsx +0 -0
  287. /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.tsx +0 -0
  288. /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.render.spec.tsx +0 -0
  289. /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.spec.ts +0 -0
  290. /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.tsx +0 -0
  291. /package/src/components/{DashboardBuilder → ReportBuilder}/FilterStrip.tsx +0 -0
  292. /package/src/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.tsx +0 -0
  293. /package/src/components/{DashboardBuilder → ReportBuilder}/InlineText.tsx +0 -0
  294. /package/src/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.tsx +0 -0
  295. /package/src/components/{DashboardBuilder → ReportBuilder}/TextTileBody.tsx +0 -0
  296. /package/src/components/{DashboardBuilder → ReportBuilder}/TileFrame.tsx +0 -0
  297. /package/src/components/{DashboardBuilder → ReportBuilder}/TileMenu.tsx +0 -0
  298. /package/src/components/{DashboardBuilder → ReportBuilder}/__test__/inventory.ts +0 -0
  299. /package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.ts +0 -0
  300. /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.spec.ts +0 -0
  301. /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.ts +0 -0
  302. /package/src/components/{DashboardBuilder → ReportBuilder}/artifactTagParity.spec.ts +0 -0
  303. /package/src/components/{DashboardBuilder → ReportBuilder}/catalog.aggregate.spec.ts +0 -0
  304. /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.spec.ts +0 -0
  305. /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.ts +0 -0
  306. /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.spec.ts +0 -0
  307. /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.ts +0 -0
  308. /package/src/components/{DashboardBuilder → ReportBuilder}/controls.ts +0 -0
  309. /package/src/components/{DashboardBuilder → ReportBuilder}/emptyStart.spec.ts +0 -0
  310. /package/src/components/{DashboardBuilder → ReportBuilder}/inlineEdit.tsx +0 -0
  311. /package/src/components/{DashboardBuilder → ReportBuilder}/invariants.spec.ts +0 -0
  312. /package/src/components/{DashboardBuilder → ReportBuilder}/keepRowStructure.spec.ts +0 -0
  313. /package/src/components/{DashboardBuilder → ReportBuilder}/layout.ts +0 -0
  314. /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.spec.ts +0 -0
  315. /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.ts +0 -0
  316. /package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.spec.ts +0 -0
  317. /package/src/components/{DashboardBuilder → ReportBuilder}/moveIntoGap.spec.ts +0 -0
  318. /package/src/components/{DashboardBuilder → ReportBuilder}/openDraft.ts +0 -0
  319. /package/src/components/{DashboardBuilder → ReportBuilder}/preview.shapes.spec.ts +0 -0
  320. /package/src/components/{DashboardBuilder → ReportBuilder}/preview.ts +0 -0
  321. /package/src/components/{DashboardBuilder → ReportBuilder}/scannerShapes.spec.ts +0 -0
  322. /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.spec.ts +0 -0
  323. /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.tsx +0 -0
  324. /package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.chart.spec.ts +0 -0
  325. /package/src/components/{DashboardBuilder → ReportBuilder}/spliceResult.ts +0 -0
  326. /package/src/components/{DashboardBuilder → ReportBuilder}/statementExtent.spec.ts +0 -0
  327. /package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.ts +0 -0
  328. /package/src/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.ts +0 -0
  329. /package/src/components/{DashboardBuilder → ReportBuilder}/testing/inline.ts +0 -0
  330. /package/src/components/{DashboardBuilder → ReportBuilder}/testing/resize.ts +0 -0
  331. /package/src/components/{DashboardBuilder → ReportBuilder}/testing/urlRenderTags.json +0 -0
  332. /package/src/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.ts +0 -0
  333. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.spec.ts +0 -0
  334. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.ts +0 -0
  335. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.overlay.spec.tsx +0 -0
  336. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.spec.tsx +0 -0
  337. /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.ts +0 -0
  338. /package/src/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.ts +0 -0
  339. /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.spec.ts +0 -0
  340. /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.ts +0 -0
  341. /package/src/components/{DashboardBuilder → ReportBuilder}/useDraft.ts +0 -0
  342. /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.spec.ts +0 -0
  343. /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.ts +0 -0
  344. /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.existing.spec.tsx +0 -0
  345. /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.spec.tsx +0 -0
  346. /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.ts +0 -0
  347. /package/src/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.ts +0 -0
  348. /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.spec.tsx +0 -0
  349. /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.ts +0 -0
  350. /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.spec.tsx +0 -0
  351. /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.ts +0 -0
  352. /package/src/components/{DashboardBuilder → ReportBuilder}/withGaps.spec.ts +0 -0
  353. /package/src/components/{Notebook → legacy}/Notebook.layout.spec.tsx +0 -0
@@ -0,0 +1,145 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { fireEvent, render, screen, waitFor } from "@testing-library/react";
5
+ import { describe, expect, it, mock } from "bun:test";
6
+ import type { ReportEvent } from "../Report/telemetry";
7
+ import { ReportBuilder } from "./ReportBuilder";
8
+ import { openDocument } from "./testing/fixtures";
9
+
10
+ /**
11
+ * The layout switch: one editor for both layouts, and switching rewrites the
12
+ * tag's `layout=` and nothing else (docs/reports-design.md §2, §10).
13
+ */
14
+ const LINEAR = `## artifact { layout=linear title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] }
15
+ import "../data_app.malloy"
16
+
17
+ source: a is scoped_orders extend {
18
+ # label="By category"
19
+ view: by_cat is by_category
20
+
21
+ view: by_brand is by_brand_view
22
+ }`;
23
+
24
+ const GRID = `## artifact { layout=grid title="Storefront" tiles=["a -> by_cat", "a -> by_brand"] } dashboard { columns=12 }
25
+ import "../data_app.malloy"
26
+
27
+ source: a is scoped_orders extend {
28
+ # colspan=6
29
+ # label="By category"
30
+ view: by_cat is by_category
31
+
32
+ # colspan=6
33
+ view: by_brand is by_brand_view
34
+ }`;
35
+
36
+ const button = (name: string | RegExp) =>
37
+ screen.getByRole("button", { name, hidden: true });
38
+
39
+ const mount = async (
40
+ source: string,
41
+ onSave: (source: string) => Promise<void> | void,
42
+ textHeld = false,
43
+ ) =>
44
+ render(
45
+ <ReportBuilder
46
+ source={source}
47
+ document={await openDocument(source)}
48
+ onSave={onSave}
49
+ {...(textHeld ? { visibleSources: ["scoped_orders"] } : {})}
50
+ />,
51
+ );
52
+
53
+ describe("the layout switch", () => {
54
+ it("shows Linear and Grid for a file, the file's own layout pressed", async () => {
55
+ await mount(LINEAR, () => {});
56
+ expect(button("Linear layout").getAttribute("aria-pressed")).toBe("true");
57
+ expect(button("Grid layout").getAttribute("aria-pressed")).toBe("false");
58
+ });
59
+
60
+ it("is not offered when the host turns it off with allowLayoutChange={false}", async () => {
61
+ render(
62
+ <ReportBuilder
63
+ source={GRID}
64
+ document={await openDocument(GRID)}
65
+ onSave={() => {}}
66
+ allowLayoutChange={false}
67
+ />,
68
+ );
69
+ expect(
70
+ screen.queryByRole("button", { name: "Grid layout", hidden: true }),
71
+ ).toBeNull();
72
+ expect(
73
+ screen.queryByRole("button", { name: "Linear layout", hidden: true }),
74
+ ).toBeNull();
75
+ });
76
+
77
+ it("is not offered for a document held as text, whose layout is the host's record", async () => {
78
+ await mount(LINEAR, () => {}, true);
79
+ expect(
80
+ screen.queryByRole("button", { name: "Grid layout", hidden: true }),
81
+ ).toBeNull();
82
+ });
83
+
84
+ it("switches linear to grid by rewriting layout= and nothing else", async () => {
85
+ const onSave = mock((_source: string) => Promise.resolve());
86
+ await mount(LINEAR, onSave);
87
+ fireEvent.click(button("Grid layout"));
88
+ await waitFor(() =>
89
+ expect(button("Grid layout").getAttribute("aria-pressed")).toBe(
90
+ "true",
91
+ ),
92
+ );
93
+ fireEvent.click(button("Save"));
94
+ await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
95
+ expect(onSave.mock.calls[0][0]).toBe(
96
+ LINEAR.replace("layout=linear", "layout=grid"),
97
+ );
98
+ });
99
+
100
+ // KNOWN BUG, not yet fixed in source: the switch sets only the document's
101
+ // kind, and the splice refuses a linear document whose `columns` is still
102
+ // set ("one column"), so a grid report with `dashboard { columns=N }`
103
+ // cannot be switched to linear. The design keeps the file's own
104
+ // `dashboard { columns=N }` and changes only `layout=`.
105
+ it("switches grid to linear by rewriting layout= and nothing else, keeping the file's width", async () => {
106
+ const onSave = mock((_source: string) => Promise.resolve());
107
+ await mount(GRID, onSave);
108
+ fireEvent.click(button("Linear layout"));
109
+ fireEvent.click(button("Save"));
110
+ await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
111
+ expect(onSave.mock.calls[0][0]).toBe(
112
+ GRID.replace("layout=grid", "layout=linear"),
113
+ );
114
+ });
115
+
116
+ it("reports a switch once, and the save after it under the new layout", async () => {
117
+ const onEvent = mock((_event: ReportEvent) => {});
118
+ render(
119
+ <ReportBuilder
120
+ source={LINEAR}
121
+ document={await openDocument(LINEAR)}
122
+ onSave={() => Promise.resolve()}
123
+ modelPath="store/front.malloy"
124
+ onEvent={onEvent}
125
+ />,
126
+ );
127
+ fireEvent.click(button("Grid layout"));
128
+ // The layout already pressed is not a switch.
129
+ fireEvent.click(button("Grid layout"));
130
+ fireEvent.click(button("Save"));
131
+ await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(2));
132
+ expect(onEvent.mock.calls[0][0]).toEqual({
133
+ type: "report.layout_changed",
134
+ path: "store/front.malloy",
135
+ layout: "grid",
136
+ from: "linear",
137
+ to: "grid",
138
+ });
139
+ expect(onEvent.mock.calls[1][0]).toMatchObject({
140
+ type: "report.saved",
141
+ path: "store/front.malloy",
142
+ layout: "grid",
143
+ });
144
+ });
145
+ });
@@ -12,13 +12,13 @@ import {
12
12
  import { afterEach, describe, expect, it, mock } from "bun:test";
13
13
  import * as fs from "fs";
14
14
  import * as path from "path";
15
- import { DashboardBuilder } from "./DashboardBuilder";
15
+ import { ReportBuilder } from "./ReportBuilder";
16
16
  import { readForEditor } from "./readForEditor";
17
17
  import { openDocument } from "./testing/fixtures";
18
- import type { BuilderEvent } from "./telemetry";
18
+ import type { ReportEvent } from "../Report/telemetry";
19
19
  import { editInline } from "./testing/inline";
20
20
 
21
- const NOTEBOOK = `## artifact { kind=notebook title="Review" tiles=[intro { kind=text }, "a -> by_cat"] }
21
+ const NOTEBOOK = `## artifact { layout=linear title="Review" tiles=[intro { kind=text }, "a -> by_cat"] }
22
22
  import "../data_app.malloy"
23
23
 
24
24
  ##|(markdown) intro
@@ -59,7 +59,7 @@ const catalog = {
59
59
  const REPO = path.resolve(import.meta.dir, "../../../../..");
60
60
  const LEGACY = fs
61
61
  .readFileSync(
62
- path.join(REPO, "examples/storefront/notebooks/category-review.malloy"),
62
+ path.join(REPO, "examples/storefront/category-review.malloy"),
63
63
  "utf8",
64
64
  )
65
65
  .replace(/\r\n/g, "\n");
@@ -73,12 +73,12 @@ const mountText = async (
73
73
  source: string,
74
74
  options: {
75
75
  onSave?: (source: string) => void;
76
- onEvent?: (event: BuilderEvent) => void;
76
+ onEvent?: (event: ReportEvent) => void;
77
77
  withCatalog?: boolean;
78
78
  } = {},
79
79
  ) =>
80
80
  render(
81
- <DashboardBuilder
81
+ <ReportBuilder
82
82
  source={source}
83
83
  document={await openDocument(source)}
84
84
  {...(options.withCatalog ? { catalog } : {})}
@@ -87,7 +87,7 @@ const mountText = async (
87
87
  />,
88
88
  );
89
89
 
90
- describe("DashboardBuilder: a notebook is one column", () => {
90
+ describe("ReportBuilder: a notebook is one column", () => {
91
91
  it("draws its text and description bare, as the notebook reader does", async () => {
92
92
  await mountText(NOTEBOOK);
93
93
  for (const card of document.querySelectorAll("[data-chrome]"))
@@ -195,23 +195,24 @@ describe("DashboardBuilder: a notebook is one column", () => {
195
195
  expect(screen.queryByLabelText("Add tile at the end")).toBeNull();
196
196
  });
197
197
 
198
- it("reports notebook events, with the cell count", async () => {
199
- const onEvent = mock((_event: BuilderEvent) => {});
198
+ it("reports a save with the cell count, the path and the linear layout", async () => {
199
+ const onEvent = mock((_event: ReportEvent) => {});
200
200
  await mountText(NOTEBOOK, { onSave: () => {}, onEvent });
201
201
  editInline("By cat", "Tile title", "Categories");
202
202
  fireEvent.click(button("Save"));
203
203
  await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
204
204
  expect(onEvent.mock.calls[0][0]).toMatchObject({
205
- type: "notebook.saved",
206
- cells: 2,
205
+ type: "report.saved",
206
+ layout: "linear",
207
+ tiles: 2,
207
208
  structural: false,
208
- converted: false,
209
209
  where: "package",
210
210
  });
211
+ expect(onEvent.mock.calls[0][0]).not.toHaveProperty("converted");
211
212
  });
212
213
  });
213
214
 
214
- describe("DashboardBuilder: a document's kind", () => {
215
+ describe("ReportBuilder: a document's kind", () => {
215
216
  it("is fixed once created: there is no switch between dashboard and notebook", async () => {
216
217
  await mountText(DASHBOARD, { onSave: () => {} });
217
218
  expect(screen.queryByRole("button", { name: "Settings" })).toBeNull();
@@ -219,11 +220,11 @@ describe("DashboardBuilder: a document's kind", () => {
219
220
  });
220
221
  });
221
222
 
222
- describe("DashboardBuilder: a notebook in the cell format", () => {
223
+ describe("ReportBuilder: a notebook in the cell format", () => {
223
224
  const open = async (
224
225
  options: {
225
226
  onSave?: (source: string) => void;
226
- onEvent?: (event: BuilderEvent) => void;
227
+ onEvent?: (event: ReportEvent) => void;
227
228
  onDirtyChange?: (dirty: boolean) => void;
228
229
  } = {},
229
230
  ) => {
@@ -231,7 +232,7 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
231
232
  if (result.ok === false) throw new Error(result.reason);
232
233
  if (!result.conversion) throw new Error("expected a conversion");
233
234
  render(
234
- <DashboardBuilder
235
+ <ReportBuilder
235
236
  source={LEGACY}
236
237
  document={result.document}
237
238
  conversion={result.conversion}
@@ -246,7 +247,7 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
246
247
  await open({ onSave: () => {}, onDirtyChange });
247
248
  expect(
248
249
  screen.getByText(
249
- /This notebook is in the cell format\. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view\./,
250
+ /This report is in the cell format\. Saving rewrites it as a layout notebook, and a named query run once becomes that tile's view\./,
250
251
  ),
251
252
  ).toBeDefined();
252
253
  expect(button("Save")).toBeDefined();
@@ -267,7 +268,7 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
267
268
  fireEvent.click(button("Save"));
268
269
  expect(
269
270
  await screen.findByText(
270
- /Saving rewrites this notebook in the tile layout/,
271
+ /Saving rewrites this report in the tile layout/,
271
272
  ),
272
273
  ).toBeDefined();
273
274
  expect(writes).toHaveLength(0);
@@ -287,7 +288,7 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
287
288
 
288
289
  it("saves the conversion exactly as converted", async () => {
289
290
  const writes: string[] = [];
290
- const onEvent = mock((_event: BuilderEvent) => {});
291
+ const onEvent = mock((_event: ReportEvent) => {});
291
292
  const conversion = await open({
292
293
  onSave: (source) => void writes.push(source),
293
294
  onEvent,
@@ -300,11 +301,11 @@ describe("DashboardBuilder: a notebook in the cell format", () => {
300
301
  // Nothing was edited, so the file written is the conversion itself.
301
302
  expect(writes[0]).toBe(conversion.to);
302
303
  expect(onEvent.mock.calls[0][0]).toMatchObject({
303
- type: "notebook.saved",
304
+ type: "report.saved",
304
305
  converted: true,
305
306
  });
306
307
  expect(
307
- screen.queryByText(/This notebook is in the cell format/),
308
+ screen.queryByText(/This report is in the cell format/),
308
309
  ).toBeNull();
309
310
  });
310
311
  });
@@ -9,7 +9,7 @@ import {
9
9
  waitFor,
10
10
  } from "@testing-library/react";
11
11
  import { afterEach, describe, expect, it, mock } from "bun:test";
12
- import { DashboardBuilder } from "./DashboardBuilder";
12
+ import { ReportBuilder } from "./ReportBuilder";
13
13
  import { openDocument } from "./testing/fixtures";
14
14
 
15
15
  const SOURCE = `## artifact { title="Storefront" tiles=["a -> by_cat"] } dashboard { columns=12 }
@@ -29,7 +29,7 @@ const mount = async (
29
29
  ) => {
30
30
  const document = await openDocument(SOURCE);
31
31
  return render(
32
- <DashboardBuilder
32
+ <ReportBuilder
33
33
  source={SOURCE}
34
34
  document={document}
35
35
  {...(options.onSave ? { onSave: options.onSave } : {})}
@@ -53,7 +53,7 @@ const type = (field: HTMLElement, value: string) =>
53
53
 
54
54
  afterEach(cleanup);
55
55
 
56
- describe("DashboardBuilder: an open inline draft", () => {
56
+ describe("ReportBuilder: an open inline draft", () => {
57
57
  it("is clean again once the committed draft is saved, and stays open", async () => {
58
58
  const onDirtyChange = mock((_dirty: boolean) => {});
59
59
  const onSave = mock(async (_source: string) => {});
@@ -10,10 +10,10 @@ import {
10
10
  within,
11
11
  } from "@testing-library/react";
12
12
  import { afterEach, describe, expect, it } from "bun:test";
13
- import { DashboardBuilder } from "./DashboardBuilder";
13
+ import { ReportBuilder } from "./ReportBuilder";
14
14
  import { openDocument } from "./testing/fixtures";
15
15
 
16
- const NOTEBOOK = `## artifact { kind=notebook title="Review" tiles=["a -> by_cat"] }
16
+ const NOTEBOOK = `## artifact { layout=linear title="Review" tiles=["a -> by_cat"] }
17
17
  import { scoped_orders } from "../data_app.malloy"
18
18
  import { spare } from "../spare.malloy"
19
19
 
@@ -41,13 +41,17 @@ const catalog = {
41
41
  ],
42
42
  };
43
43
 
44
- const mount = async (onSave: (source: string) => void) =>
44
+ // One folder down, which is what its `../` imports say; `atRoot` is the same
45
+ // report at the package root, reading its models from beside it.
46
+ const AT_ROOT = NOTEBOOK.replace(/"\.\.\//g, '"');
47
+ const mount = async (onSave: (source: string) => void, atRoot = false) =>
45
48
  render(
46
- <DashboardBuilder
47
- source={NOTEBOOK}
48
- document={await openDocument(NOTEBOOK)}
49
+ <ReportBuilder
50
+ source={atRoot ? AT_ROOT : NOTEBOOK}
51
+ document={await openDocument(atRoot ? AT_ROOT : NOTEBOOK)}
49
52
  catalog={catalog}
50
53
  onSave={onSave}
54
+ modelPath={atRoot ? "review.malloy" : "notebooks/review.malloy"}
51
55
  />,
52
56
  );
53
57
 
@@ -73,11 +77,11 @@ const addTileOn = (name: string) => {
73
77
  );
74
78
  };
75
79
 
76
- const written = async (pick: string) => {
80
+ const written = async (pick: string, atRoot = false) => {
77
81
  let text: string | undefined;
78
82
  await mount((source) => {
79
83
  text = source;
80
- });
84
+ }, atRoot);
81
85
  addTileOn(pick);
82
86
  save();
83
87
  await waitFor(() => expect(text).toBeDefined());
@@ -110,6 +114,13 @@ describe("adding a tile brings its source in", () => {
110
114
  );
111
115
  });
112
116
 
117
+ it("writes the import relative to a report at the package root, with no leading ../", async () => {
118
+ const text = await written("reports", true);
119
+ expect(text).toContain(
120
+ 'import { spare } from "spare.malloy"\nimport { reports } from "reports.malloy"\n',
121
+ );
122
+ });
123
+
113
124
  it("joins an import of a model that re-exports the source rather than adding another model's", async () => {
114
125
  const text = await written("events");
115
126
  expect(text).toContain('import { spare, events } from "../spare.malloy"');
@@ -10,8 +10,8 @@ import {
10
10
  within,
11
11
  } from "@testing-library/react";
12
12
  import { describe, expect, it, mock } from "bun:test";
13
- import type { DashboardEvent } from "../Dashboard/telemetry";
14
- import { DashboardBuilder } from "./DashboardBuilder";
13
+ import type { ReportEvent } from "../Report/telemetry";
14
+ import { ReportBuilder } from "./ReportBuilder";
15
15
  import { openDocument } from "./testing/fixtures";
16
16
  import { closeMenu, editInline } from "./testing/inline";
17
17
  import { dragEdge } from "./testing/resize";
@@ -31,11 +31,11 @@ source: a is scoped_orders extend {
31
31
 
32
32
  const mount = async (
33
33
  onSave?: (source: string) => Promise<void> | void,
34
- onEvent?: (event: DashboardEvent) => void,
34
+ onEvent?: (event: ReportEvent) => void,
35
35
  ) => {
36
36
  const document = await openDocument(SOURCE);
37
37
  return render(
38
- <DashboardBuilder
38
+ <ReportBuilder
39
39
  source={SOURCE}
40
40
  document={document}
41
41
  {...(onSave ? { onSave } : {})}
@@ -101,7 +101,7 @@ const itemStyleOf = (name: string): string => {
101
101
  return declarations.join(" ");
102
102
  };
103
103
 
104
- describe("DashboardBuilder", () => {
104
+ describe("ReportBuilder", () => {
105
105
  it("shows a tile per entry, titled as a reader would see it", async () => {
106
106
  await mount();
107
107
  // The labelled tile shows its label; the unlabelled one falls back to the
@@ -155,7 +155,7 @@ describe("DashboardBuilder", () => {
155
155
  it("hands the whole tile to renderTile, adding no heading of its own", async () => {
156
156
  const document = await openDocument(SOURCE);
157
157
  render(
158
- <DashboardBuilder
158
+ <ReportBuilder
159
159
  source={SOURCE}
160
160
  document={document}
161
161
  renderTile={(each) => <article>a real {each.name}</article>}
@@ -173,7 +173,7 @@ describe("DashboardBuilder", () => {
173
173
  it("marks selection without resizing the tile", async () => {
174
174
  const document = await openDocument(SOURCE);
175
175
  render(
176
- <DashboardBuilder
176
+ <ReportBuilder
177
177
  source={SOURCE}
178
178
  document={document}
179
179
  renderTile={(each) => <article>a real {each.name}</article>}
@@ -205,11 +205,11 @@ describe("DashboardBuilder", () => {
205
205
  });
206
206
  });
207
207
 
208
- describe("DashboardBuilder: the dashboard's filters", () => {
208
+ describe("ReportBuilder: the dashboard's filters", () => {
209
209
  // The convention, end to end through the surface: a filter added here is a
210
210
  // declaration in THIS file plus a binding on each ticked tile, and the save
211
211
  // writes exactly that.
212
- it("adds a filter declared in this dashboard and writes it to the file", async () => {
212
+ it("adds a filter declared in this report and writes it to the file", async () => {
213
213
  let written: string | undefined;
214
214
  await mount((source) => {
215
215
  written = source;
@@ -255,7 +255,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
255
255
  let written: string | undefined;
256
256
  const document = await openDocument(SOURCE);
257
257
  render(
258
- <DashboardBuilder
258
+ <ReportBuilder
259
259
  source={SOURCE}
260
260
  document={document}
261
261
  givens={[
@@ -295,7 +295,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
295
295
  );
296
296
  const document = await openDocument(source);
297
297
  render(
298
- <DashboardBuilder
298
+ <ReportBuilder
299
299
  source={source}
300
300
  document={document}
301
301
  onSave={(next) => {
@@ -319,7 +319,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
319
319
  );
320
320
  const document = await openDocument(source);
321
321
  render(
322
- <DashboardBuilder
322
+ <ReportBuilder
323
323
  source={source}
324
324
  document={document}
325
325
  onSave={(next) => {
@@ -346,7 +346,7 @@ describe("DashboardBuilder: the dashboard's filters", () => {
346
346
  });
347
347
  });
348
348
 
349
- describe("DashboardBuilder: fields, when the package is known", () => {
349
+ describe("ReportBuilder: fields, when the package is known", () => {
350
350
  const catalog = {
351
351
  sources: [
352
352
  {
@@ -378,7 +378,7 @@ describe("DashboardBuilder: fields, when the package is known", () => {
378
378
  const mountWithCatalog = async () => {
379
379
  const document = await openDocument(SOURCE);
380
380
  return render(
381
- <DashboardBuilder
381
+ <ReportBuilder
382
382
  source={SOURCE}
383
383
  document={document}
384
384
  catalog={catalog}
@@ -449,7 +449,7 @@ describe("DashboardBuilder: fields, when the package is known", () => {
449
449
  );
450
450
  const document = await openDocument(source);
451
451
  render(
452
- <DashboardBuilder
452
+ <ReportBuilder
453
453
  source={source}
454
454
  document={document}
455
455
  catalog={catalog}
@@ -460,7 +460,7 @@ describe("DashboardBuilder: fields, when the package is known", () => {
460
460
  });
461
461
  });
462
462
 
463
- describe("DashboardBuilder: a control the model declares", () => {
463
+ describe("ReportBuilder: a control the model declares", () => {
464
464
  // Its declaration is not ours to delete, but a control is a given some tile
465
465
  // binds, so taking it off the dashboard is unbinding every tile.
466
466
  it("can still be taken off the dashboard", async () => {
@@ -481,7 +481,7 @@ describe("DashboardBuilder: a control the model declares", () => {
481
481
  });
482
482
  });
483
483
 
484
- describe("DashboardBuilder: tiles added and removed", () => {
484
+ describe("ReportBuilder: tiles added and removed", () => {
485
485
  // A catalog whose source the fixture's extension is built on, with a view
486
486
  // to put on the page. `scoped_orders` is reachable because `a` extends it.
487
487
  const catalogWithViews = {
@@ -504,7 +504,7 @@ describe("DashboardBuilder: tiles added and removed", () => {
504
504
  const mountWithCatalog = async (onSave: (source: string) => void) => {
505
505
  const document = await openDocument(SOURCE);
506
506
  return render(
507
- <DashboardBuilder
507
+ <ReportBuilder
508
508
  source={SOURCE}
509
509
  document={document}
510
510
  catalog={catalogWithViews}
@@ -562,7 +562,7 @@ describe("DashboardBuilder: tiles added and removed", () => {
562
562
  });
563
563
  });
564
564
 
565
- describe("DashboardBuilder: the last tile", () => {
565
+ describe("ReportBuilder: the last tile", () => {
566
566
  it("cannot be removed while the saved dashboard has tiles, and says why on screen", async () => {
567
567
  await mount();
568
568
  fireEvent.click(screen.getByLabelText("Settings for By category"));
@@ -571,7 +571,7 @@ describe("DashboardBuilder: the last tile", () => {
571
571
  const remove = screen.getByRole("button", { name: /^Delete/ });
572
572
  expect(remove.getAttribute("aria-disabled")).toBe("true");
573
573
  const reason = screen.getByText(
574
- "A saved dashboard needs at least one tile.",
574
+ "A saved report needs at least one tile.",
575
575
  );
576
576
  expect(remove.getAttribute("aria-describedby")).toBe(reason.id);
577
577
  fireEvent.click(remove);
@@ -579,7 +579,7 @@ describe("DashboardBuilder: the last tile", () => {
579
579
  });
580
580
  });
581
581
 
582
- describe("DashboardBuilder: a tile's own settings", () => {
582
+ describe("ReportBuilder: a tile's own settings", () => {
583
583
  it("retitles a tile where it is shown, one history entry per commit", async () => {
584
584
  await mount();
585
585
  editInline("By category", "Tile title", "Revenue by category");
@@ -606,7 +606,7 @@ describe("DashboardBuilder: a tile's own settings", () => {
606
606
  it("offers no title to a tile the model owns", async () => {
607
607
  const source = `## artifact { title="T" tiles=["orders -> by_brand"] }\nimport { orders } from '../orders.malloy'`;
608
608
  const document = await openDocument(source);
609
- render(<DashboardBuilder source={source} document={document} />);
609
+ render(<ReportBuilder source={source} document={document} />);
610
610
  fireEvent.click(screen.getByLabelText("Settings for by_brand"));
611
611
  expect(screen.queryByLabelText("Tile title")).toBeNull();
612
612
  expect(screen.getByText(/Declared on its source/)).toBeDefined();
@@ -616,7 +616,7 @@ describe("DashboardBuilder: a tile's own settings", () => {
616
616
  });
617
617
  });
618
618
 
619
- describe("DashboardBuilder: widths and the page's own settings", () => {
619
+ describe("ReportBuilder: widths and the page's own settings", () => {
620
620
  it("steps a tile's width from the keyboard on its edge, one undo step each", async () => {
621
621
  await mount();
622
622
  const edge = screen.getByRole("separator", {
@@ -659,7 +659,7 @@ describe("DashboardBuilder: widths and the page's own settings", () => {
659
659
  fireEvent.keyDown(description, { key: "Escape" });
660
660
  expect(screen.getByText("What sold, and where.")).toBeDefined();
661
661
 
662
- editInline("Storefront", "Dashboard title", "Storefront, weekly");
662
+ editInline("Storefront", "Report title", "Storefront, weekly");
663
663
  expect(screen.getByText("Storefront, weekly")).toBeDefined();
664
664
 
665
665
  fireEvent.click(button("Save"));
@@ -675,7 +675,7 @@ describe("DashboardBuilder: widths and the page's own settings", () => {
675
675
  });
676
676
  });
677
677
 
678
- describe("DashboardBuilder: clickable cells", () => {
678
+ describe("ReportBuilder: clickable cells", () => {
679
679
  const WITH_DIMENSION = `## artifact { title="T" tiles=["a -> x"] } dashboard { columns=12 }
680
680
  import "../data_app.malloy"
681
681
 
@@ -691,7 +691,7 @@ source: a is scoped_orders extend {
691
691
  let saved = "";
692
692
  const doc = await openDocument(WITH_DIMENSION);
693
693
  render(
694
- <DashboardBuilder
694
+ <ReportBuilder
695
695
  source={WITH_DIMENSION}
696
696
  document={doc}
697
697
  dashboards={["regions"]}
@@ -708,7 +708,7 @@ source: a is scoped_orders extend {
708
708
  screen.getByRole("combobox", { name: /Clicks go to/, hidden: true }),
709
709
  );
710
710
  fireEvent.click(
711
- screen.getByRole("option", { name: /This dashboard/, hidden: true }),
711
+ screen.getByRole("option", { name: /This report/, hidden: true }),
712
712
  );
713
713
  fireEvent.click(
714
714
  screen.getByRole("option", { name: /regions/, hidden: true }),
@@ -745,7 +745,7 @@ source: a is scoped_orders extend {
745
745
  });
746
746
  });
747
747
 
748
- describe("DashboardBuilder: keyboard", () => {
748
+ describe("ReportBuilder: keyboard", () => {
749
749
  it("undoes and redoes from the keyboard, and never from inside a text field", async () => {
750
750
  await mount();
751
751
  retitle("By category", "Renamed");
@@ -804,7 +804,7 @@ describe("DashboardBuilder: keyboard", () => {
804
804
  });
805
805
  });
806
806
 
807
- describe("DashboardBuilder: history", () => {
807
+ describe("ReportBuilder: history", () => {
808
808
  it("enables undo only once there is something to undo", async () => {
809
809
  await mount();
810
810
  expect(button("Undo")).toHaveProperty("disabled", true);
@@ -825,7 +825,7 @@ describe("DashboardBuilder: history", () => {
825
825
  });
826
826
  });
827
827
 
828
- describe("DashboardBuilder: saving", () => {
828
+ describe("ReportBuilder: saving", () => {
829
829
  it("offers no save button when there is nowhere to save", async () => {
830
830
  await mount();
831
831
  expect(screen.queryByRole("button", { name: /Save|Saved/ })).toBeNull();
@@ -833,7 +833,7 @@ describe("DashboardBuilder: saving", () => {
833
833
 
834
834
  it("writes the change into the file, comment and all, and says so", async () => {
835
835
  let written: string | undefined;
836
- const onEvent = mock((_event: DashboardEvent) => {});
836
+ const onEvent = mock((_event: ReportEvent) => {});
837
837
  await mount((source) => {
838
838
  written = source;
839
839
  }, onEvent);
@@ -855,7 +855,7 @@ describe("DashboardBuilder: saving", () => {
855
855
  await waitFor(() => expect(button("Saved")).toBeDefined());
856
856
  expect(onEvent).toHaveBeenCalledTimes(1);
857
857
  expect(onEvent.mock.calls[0][0]).toMatchObject({
858
- type: "dashboard.saved",
858
+ type: "report.saved",
859
859
  tiles: 2,
860
860
  structural: false,
861
861
  // Where it went: a save into the package is a change every reader of
@@ -869,7 +869,7 @@ describe("DashboardBuilder: saving", () => {
869
869
  // The rule the writer rests on, shown through the surface: the work stays on
870
870
  // screen and the reason is visible.
871
871
  it("keeps the edit on screen when a save is refused, and says why", async () => {
872
- const onEvent = mock((_event: DashboardEvent) => {});
872
+ const onEvent = mock((_event: ReportEvent) => {});
873
873
  await mount(() => {
874
874
  throw new Error("disk full");
875
875
  }, onEvent);
@@ -880,7 +880,7 @@ describe("DashboardBuilder: saving", () => {
880
880
  expect(screen.getByRole("alert").textContent).toContain("disk full"),
881
881
  );
882
882
  expect(onEvent.mock.calls[0][0]).toMatchObject({
883
- type: "dashboard.save_refused",
883
+ type: "report.save_refused",
884
884
  reason: expect.stringContaining("disk full"),
885
885
  });
886
886
  // The edit is still on screen and still unsaved.