@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
@@ -0,0 +1,426 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ /**
5
+ * The contract the SDK holds a host's {@link DocumentStorage} to today: every
6
+ * call each caller makes, with the exact locator. A host's store (the
7
+ * Console's browser store, a platform's own) is written against these calls,
8
+ * so a change to any of them is a change to that contract and must be made
9
+ * here on purpose.
10
+ *
11
+ * A locator is `{ workspace, type, path }`: `path` is
12
+ * `<environment>/<package>/<package path>` and is the document's identity,
13
+ * and `type` is the report's layout (`grid` or `linear`), metadata a save
14
+ * records and a listing reports. One path is one document whatever its layout.
15
+ */
16
+ import {
17
+ act,
18
+ fireEvent,
19
+ render,
20
+ renderHook,
21
+ screen,
22
+ waitFor,
23
+ } from "@testing-library/react";
24
+ import { QueryClient } from "@tanstack/react-query";
25
+ import { beforeEach, describe, expect, it } from "bun:test";
26
+ import type { ReactNode } from "react";
27
+ import {
28
+ clearCache,
29
+ mockServerProvider,
30
+ pending,
31
+ serverWrapper,
32
+ } from "../../../test/serverProvider";
33
+ import { createDocument } from "../DocumentCreate/createDocument";
34
+ import { useHostCopy } from "../ReportBuilder/useHostCopy";
35
+ import { useSaveChannel } from "../ReportBuilder/useSaveChannel";
36
+ import { findDraftLayout } from "../Package/useDraftLayout";
37
+ import { BrowserDocumentStorage } from "./BrowserDocumentStorage";
38
+ import {
39
+ DocumentNotFoundError,
40
+ type DocumentLocator,
41
+ type DocumentStorage,
42
+ type DocumentType,
43
+ type Workspace,
44
+ } from "./DocumentStorage";
45
+ import { DocumentStorageProvider } from "./DocumentStorageProvider";
46
+
47
+ mockServerProvider(
48
+ {
49
+ packages: { getPackage: pending },
50
+ reports: {
51
+ listReports: () => Promise.resolve({ data: [] }),
52
+ getReport: pending,
53
+ },
54
+ models: { listModels: () => Promise.resolve({ data: [] }) },
55
+ databases: { listDatabases: () => Promise.resolve({ data: [] }) },
56
+ dataApps: { listDataApps: () => Promise.resolve({ data: [] }) },
57
+ materializations: {
58
+ listMaterializations: () => Promise.resolve({ data: [] }),
59
+ },
60
+ },
61
+ { mutable: true },
62
+ );
63
+ const { default: Package } = await import("../Package/Package");
64
+
65
+ const RECORD: Workspace = {
66
+ name: "record",
67
+ writeable: true,
68
+ description: "The record",
69
+ authoritative: true,
70
+ };
71
+ const SCRATCH: Workspace = {
72
+ name: "scratch",
73
+ writeable: true,
74
+ description: "Scratch space",
75
+ };
76
+ const READ_ONLY: Workspace = {
77
+ name: "archive",
78
+ writeable: false,
79
+ description: "Read only",
80
+ };
81
+
82
+ type Call = [method: string, ...args: unknown[]];
83
+
84
+ /** A store that answers from a fixed set of documents and records every call verbatim. */
85
+ function recordingStorage(
86
+ workspaces: Workspace[],
87
+ documents: (DocumentLocator & { content?: string })[] = [],
88
+ ) {
89
+ const calls: Call[] = [];
90
+ const find = (l: DocumentLocator) =>
91
+ documents.find((d) => d.workspace === l.workspace && d.path === l.path);
92
+ const storage: DocumentStorage = {
93
+ listWorkspaces: async (writeableOnly) => {
94
+ calls.push(["listWorkspaces", writeableOnly]);
95
+ return workspaces;
96
+ },
97
+ listDocuments: async (workspace, type) => {
98
+ calls.push(["listDocuments", workspace.name, type]);
99
+ return documents
100
+ .filter(
101
+ (d) =>
102
+ d.workspace === workspace.name &&
103
+ (type === undefined || d.type === type),
104
+ )
105
+ .map(({ workspace, type, path }) => ({ workspace, type, path }));
106
+ },
107
+ getDocument: async (locator) => {
108
+ calls.push(["getDocument", locator]);
109
+ const found = find(locator);
110
+ if (!found) throw new DocumentNotFoundError("absent");
111
+ return found.content ?? "";
112
+ },
113
+ saveDocument: async (locator, content) => {
114
+ calls.push(["saveDocument", locator, content]);
115
+ },
116
+ deleteDocument: async (locator) => {
117
+ calls.push(["deleteDocument", locator]);
118
+ },
119
+ moveDocument: async (from, to) => {
120
+ calls.push(["moveDocument", from, to]);
121
+ },
122
+ };
123
+ return { storage, calls };
124
+ }
125
+
126
+ const locator = (
127
+ workspace: string,
128
+ type: DocumentType,
129
+ path: string,
130
+ ): DocumentLocator => ({ workspace, type, path });
131
+
132
+ describe("DocumentStorage contract: create", () => {
133
+ it("lists the workspace, reads the candidate, then saves it at `<env>/<pkg>/<path>`, recording the layout", async () => {
134
+ const { storage, calls } = recordingStorage([RECORD]);
135
+ await createDocument({
136
+ layout: "grid",
137
+ path: "sales/q3.malloy",
138
+ document: {
139
+ title: "Q3",
140
+ modelPath: "models/storefront.malloy",
141
+ source: "order_items",
142
+ view: "by_category",
143
+ },
144
+ target: {
145
+ route: "storage",
146
+ storage,
147
+ workspace: RECORD,
148
+ environmentName: "env",
149
+ packageName: "pkg",
150
+ },
151
+ });
152
+ const at = locator("record", "grid", "env/pkg/sales/q3.malloy");
153
+ expect(
154
+ calls.map(([method, ...args]) =>
155
+ method === "saveDocument" ? [method, args[0]] : [method, ...args],
156
+ ),
157
+ ).toEqual([
158
+ ["listDocuments", "record", undefined],
159
+ ["getDocument", at],
160
+ ["saveDocument", at],
161
+ ]);
162
+ });
163
+
164
+ it("records a linear report's layout", async () => {
165
+ const { storage, calls } = recordingStorage([RECORD]);
166
+ await createDocument({
167
+ layout: "linear",
168
+ path: "story.malloy",
169
+ document: {
170
+ title: "Story",
171
+ modelPath: "models/storefront.malloy",
172
+ source: "order_items",
173
+ view: "by_category",
174
+ },
175
+ target: {
176
+ route: "storage",
177
+ storage,
178
+ workspace: RECORD,
179
+ environmentName: "env",
180
+ packageName: "pkg",
181
+ },
182
+ });
183
+ expect(calls[0]).toEqual(["listDocuments", "record", undefined]);
184
+ expect(calls.at(-1)?.[1]).toEqual(
185
+ locator("record", "linear", "env/pkg/story.malloy"),
186
+ );
187
+ });
188
+ });
189
+
190
+ describe("DocumentStorage contract: find a draft's layout", () => {
191
+ it("lists every workspace, then the chosen one's documents of every layout, matching on the path alone and reading the layout it recorded", async () => {
192
+ const { storage, calls } = recordingStorage(
193
+ [SCRATCH, RECORD],
194
+ [
195
+ locator("record", "linear", "env/pkg/story.malloy"),
196
+ locator("scratch", "grid", "env/pkg/story.malloy"),
197
+ ],
198
+ );
199
+ expect(await findDraftLayout(storage, "env", "pkg", "story.malloy")).toBe(
200
+ "linear",
201
+ );
202
+ expect(calls).toEqual([
203
+ ["listWorkspaces", false],
204
+ ["listDocuments", "record", undefined],
205
+ ]);
206
+ });
207
+
208
+ it("asks a store that reads one document's layout for that document alone, never listing", async () => {
209
+ const { storage, calls } = recordingStorage(
210
+ [SCRATCH, RECORD],
211
+ [
212
+ locator("record", "linear", "env/pkg/story.malloy"),
213
+ locator("scratch", "grid", "env/pkg/story.malloy"),
214
+ ],
215
+ );
216
+ const documents = [locator("record", "linear", "env/pkg/story.malloy")];
217
+ storage.getDocumentType = async (at) => {
218
+ calls.push(["getDocumentType", at]);
219
+ const found = documents.find(
220
+ (d) => d.workspace === at.workspace && d.path === at.path,
221
+ );
222
+ if (!found) throw new DocumentNotFoundError("absent");
223
+ return found.type;
224
+ };
225
+ expect(await findDraftLayout(storage, "env", "pkg", "story.malloy")).toBe(
226
+ "linear",
227
+ );
228
+ expect(
229
+ await findDraftLayout(storage, "env", "pkg", "missing.malloy"),
230
+ ).toBeUndefined();
231
+ expect(calls).toEqual([
232
+ ["listWorkspaces", false],
233
+ [
234
+ "getDocumentType",
235
+ { workspace: "record", path: "env/pkg/story.malloy" },
236
+ ],
237
+ ["listWorkspaces", false],
238
+ [
239
+ "getDocumentType",
240
+ { workspace: "record", path: "env/pkg/missing.malloy" },
241
+ ],
242
+ ]);
243
+ });
244
+
245
+ it("passes on a store's failure to answer, which is not absence", async () => {
246
+ const { storage } = recordingStorage([RECORD]);
247
+ storage.getDocumentType = async () => {
248
+ throw new Error("backend down");
249
+ };
250
+ await expect(
251
+ findDraftLayout(storage, "env", "pkg", "story.malloy"),
252
+ ).rejects.toThrow("backend down");
253
+ });
254
+ });
255
+
256
+ describe("DocumentStorage contract: open (the host's copy)", () => {
257
+ const open = (storage: DocumentStorage, layout: DocumentType) =>
258
+ renderHook(() =>
259
+ useHostCopy({
260
+ storage,
261
+ layout,
262
+ notebook: layout === "linear",
263
+ environmentName: "env",
264
+ packageName: "pkg",
265
+ modelPath: "sales/q3.malloy",
266
+ }),
267
+ );
268
+
269
+ it("reads the copy at `<env>/<pkg>/<path>`, with the layout it opened with", async () => {
270
+ const { storage, calls } = recordingStorage(
271
+ [RECORD],
272
+ [
273
+ {
274
+ ...locator("record", "grid", "env/pkg/sales/q3.malloy"),
275
+ content: "saved",
276
+ },
277
+ ],
278
+ );
279
+ const { result } = open(storage, "grid");
280
+ await waitFor(() => expect(result.current.draftChecked).toBe(true));
281
+ expect(result.current.draft).toBe("saved");
282
+ expect(calls).toEqual([
283
+ ["listWorkspaces", false],
284
+ ["getDocument", locator("record", "grid", "env/pkg/sales/q3.malloy")],
285
+ ]);
286
+ });
287
+
288
+ it("finds the copy at its path whatever layout it recorded", async () => {
289
+ const { storage } = recordingStorage(
290
+ [RECORD],
291
+ [
292
+ {
293
+ ...locator("record", "linear", "env/pkg/sales/q3.malloy"),
294
+ content: "saved linear",
295
+ },
296
+ ],
297
+ );
298
+ const { result } = open(storage, "grid");
299
+ await waitFor(() => expect(result.current.draftChecked).toBe(true));
300
+ expect(result.current.draft).toBe("saved linear");
301
+ });
302
+
303
+ it("reads a notebook's copy only from an authoritative workspace", async () => {
304
+ const { storage, calls } = recordingStorage([SCRATCH]);
305
+ const { result } = open(storage, "linear");
306
+ await waitFor(() => expect(result.current.draftChecked).toBe(true));
307
+ expect(calls).toEqual([["listWorkspaces", false]]);
308
+ });
309
+ });
310
+
311
+ describe("DocumentStorage contract: save", () => {
312
+ it("saves to `<env>/<pkg>/<path>`, recording the layout the document has, or the one it opened with", async () => {
313
+ const { storage, calls } = recordingStorage([RECORD]);
314
+ const noop = () => {};
315
+ const ref = { current: undefined };
316
+ const { result } = renderHook(() =>
317
+ useSaveChannel({
318
+ storage,
319
+ workspace: RECORD,
320
+ layout: "linear",
321
+ notebook: true,
322
+ environmentName: "env",
323
+ packageName: "pkg",
324
+ modelPath: "story.malloy",
325
+ versionId: undefined,
326
+ apiClients: {} as never,
327
+ queryClient: new QueryClient(),
328
+ mutable: true,
329
+ textHeld: false,
330
+ readFailure: undefined,
331
+ authoritative: true,
332
+ resume: undefined,
333
+ setResume: noop,
334
+ setOpened: noop,
335
+ setDraft: noop,
336
+ setOffered: noop,
337
+ setSeen: noop,
338
+ setWrote: noop,
339
+ savedHashRef: ref,
340
+ packageBaseRef: ref,
341
+ fetchedAtRef: { current: 0 },
342
+ }),
343
+ );
344
+ expect(result.current.writer).toBe("storage");
345
+ await act(() => result.current.save!("the text"));
346
+ await act(() => result.current.save!("switched", "grid"));
347
+ expect(calls).toEqual([
348
+ [
349
+ "saveDocument",
350
+ locator("record", "linear", "env/pkg/story.malloy"),
351
+ "the text",
352
+ ],
353
+ [
354
+ "saveDocument",
355
+ locator("record", "grid", "env/pkg/story.malloy"),
356
+ "switched",
357
+ ],
358
+ ]);
359
+ });
360
+ });
361
+
362
+ describe("DocumentStorage contract: list and remove (the package page's drafts)", () => {
363
+ beforeEach(() => clearCache());
364
+
365
+ const mount = (storage: DocumentStorage) =>
366
+ render(
367
+ <Package
368
+ resourceUri="publisher://environments/env/packages/pkg"
369
+ onClickPackageFile={() => {}}
370
+ />,
371
+ {
372
+ wrapper: ({ children }: { children: ReactNode }) =>
373
+ serverWrapper({
374
+ children: (
375
+ <DocumentStorageProvider documentStorage={storage}>
376
+ {children}
377
+ </DocumentStorageProvider>
378
+ ),
379
+ }),
380
+ },
381
+ );
382
+
383
+ it("lists each writeable workspace's documents of every layout, and removes a draft by the locator it was listed under", async () => {
384
+ const listed = locator("scratch", "linear", "env/pkg/team/n.malloy");
385
+ const { storage, calls } = recordingStorage(
386
+ [RECORD, SCRATCH, READ_ONLY],
387
+ [listed, locator("scratch", "grid", "env/other/x.malloy")],
388
+ );
389
+ mount(storage);
390
+ fireEvent.click(
391
+ await screen.findByRole("button", {
392
+ name: "Delete draft team/n.malloy",
393
+ }),
394
+ );
395
+ await waitFor(() =>
396
+ expect(calls.some(([method]) => method === "deleteDocument")).toBe(
397
+ true,
398
+ ),
399
+ );
400
+ expect(calls.slice(0, 3)).toEqual([
401
+ ["listWorkspaces", false],
402
+ ["listDocuments", "record", undefined],
403
+ ["listDocuments", "scratch", undefined],
404
+ ]);
405
+ expect(calls.find(([method]) => method === "deleteDocument")).toEqual([
406
+ "deleteDocument",
407
+ listed,
408
+ ]);
409
+ });
410
+ });
411
+
412
+ describe("DocumentStorage contract: the browser store", () => {
413
+ beforeEach(() => localStorage.clear());
414
+
415
+ it("keys a document by its path, so a save under another layout replaces it and records that layout", async () => {
416
+ const storage = new BrowserDocumentStorage();
417
+ const asGrid = locator("Local", "grid", "env/pkg/x.malloy");
418
+ const asLinear = locator("Local", "linear", "env/pkg/x.malloy");
419
+ await storage.saveDocument(asGrid, "grid text");
420
+ await storage.saveDocument(asLinear, "linear text");
421
+ expect(await storage.getDocument(asGrid)).toBe("linear text");
422
+ const [workspace] = await storage.listWorkspaces(false);
423
+ expect(await storage.listDocuments(workspace)).toEqual([asLinear]);
424
+ expect(await storage.listDocuments(workspace, "grid")).toEqual([]);
425
+ });
426
+ });
@@ -1,6 +1,8 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
+ import type { ReportLayout } from "../Package/documentLocation";
5
+
4
6
  /**
5
7
  * Where authored documents are kept, as an interface the host hands the SDK.
6
8
  *
@@ -12,12 +14,12 @@
12
14
  * {@link DocumentStorage} through {@link DocumentStorageProvider} and calls it,
13
15
  * and never touches a backend itself.
14
16
  *
15
- * A document is a string. The interface does not know whether it is a
16
- * `dashboards/*.malloy` file, a `.malloynb`, or something else; the
17
- * {@link DocumentLocator.type} says what kind it is so a backend can keep the
18
- * kinds apart (a database column, a directory, a key prefix) and a listing can
19
- * ask for one kind. Everything else a backend may know about a document, who
20
- * changed it and when, who may see it, stays with the backend.
17
+ * A document is a string, addressed by its workspace and its path: one path is
18
+ * one document. The {@link DocumentLocator.type} is metadata beside it, the
19
+ * report's layout, which a backend keeps (a column, a field) so a listing can
20
+ * say which layout each document is without reading it, and filter by one.
21
+ * Everything else a backend may know about a document, who changed it and
22
+ * when, who may see it, stays with the backend.
21
23
  *
22
24
  * A host hands the SDK ONE storage and keeps handing it the same one. What a
23
25
  * storage says about its workspaces decides how the editor routes a save, and
@@ -53,11 +55,12 @@ export const isDocumentNotFound = (error: unknown): boolean =>
53
55
  (error instanceof Error && error.name === "DocumentNotFoundError");
54
56
 
55
57
  /**
56
- * The kinds of document the SDK authors. A `dashboard` is a
57
- * `dashboards/<slug>.malloy` file; a `notebook` is a
58
- * `notebooks/<slug>.malloy` file.
58
+ * The layout of a report the SDK authors, as a store records it beside the
59
+ * document: `grid` or `linear`. Metadata, not identity: a report's path is
60
+ * its identity wherever in the package the file lives, and a layout switch
61
+ * changes this and nothing else.
59
62
  */
60
- export type DocumentType = "dashboard" | "notebook";
63
+ export type DocumentType = ReportLayout;
61
64
 
62
65
  /** A place documents live, as the backend presents it to a reader. */
63
66
  export interface Workspace {
@@ -93,15 +96,19 @@ export interface Workspace {
93
96
  authoritative?: boolean;
94
97
  }
95
98
 
96
- /** One document's address: which workspace, which kind, and its path there. */
99
+ /**
100
+ * One document's address, `workspace` and `path`, and its layout.
101
+ *
102
+ * The SDK spells `path` as `<environment>/<package>/<package path>`
103
+ * (`draftKey`), and a store keys a document by it: a read, a delete or a move
104
+ * finds the document at `path` whatever `type` says, and a save records
105
+ * `type` as the document's layout, replacing what it was.
106
+ */
97
107
  export interface DocumentLocator {
98
108
  workspace: string;
109
+ /** The report's layout, which a save records and a listing reports. */
99
110
  type: DocumentType;
100
- /**
101
- * The document's path within the workspace, spelled the way the backend
102
- * spells it. For a repo-backed store that is the file path relative to the
103
- * package (`dashboards/overview.malloy`); a database store may use a slug.
104
- */
111
+ /** The document's identity within the workspace. */
105
112
  path: string;
106
113
  }
107
114
 
@@ -109,21 +116,34 @@ export interface DocumentStorage {
109
116
  /** The workspaces this reader can see; only the writeable ones when asked. */
110
117
  listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
111
118
 
112
- /** Every document in a workspace, or only those of one kind. */
119
+ /** Every document in a workspace, or only those of one layout, each with the layout its last save recorded. */
113
120
  listDocuments(
114
121
  workspace: Workspace,
115
122
  type?: DocumentType,
116
123
  ): Promise<DocumentLocator[]>;
117
124
 
118
125
  /**
119
- * The document's content. Rejects with a {@link DocumentNotFoundError} when
120
- * there is no document there, and with anything else when the backend could
121
- * not be asked.
126
+ * The content of the document at `locator.path`, whatever its layout.
127
+ * Rejects with a {@link DocumentNotFoundError} when there is no document
128
+ * there, and with anything else when the backend could not be asked.
122
129
  */
123
130
  getDocument(locator: DocumentLocator): Promise<string>;
124
131
 
125
132
  /**
126
- * Write the content, creating the document or replacing it.
133
+ * Optional. The layout the last save recorded for the document at
134
+ * `locator.path`, read for that document alone. Rejects with a
135
+ * {@link DocumentNotFoundError} when there is no document there, and with
136
+ * anything else when the backend could not be asked. Left out, the SDK
137
+ * finds the layout in {@link listDocuments}, which reads the whole
138
+ * workspace to answer for one document.
139
+ */
140
+ getDocumentType?(
141
+ locator: Pick<DocumentLocator, "workspace" | "path">,
142
+ ): Promise<DocumentType>;
143
+
144
+ /**
145
+ * Write the content at `locator.path`, creating the document or replacing
146
+ * it, and record `locator.type` as its layout.
127
147
  *
128
148
  * There is no expected-version slot, so this is last writer wins and a
129
149
  * caller cannot tell that it overwrote someone. A backend that has to stop
@@ -132,7 +152,7 @@ export interface DocumentStorage {
132
152
  saveDocument(locator: DocumentLocator, content: string): Promise<void>;
133
153
 
134
154
  /**
135
- * Remove the document. Rejects with a {@link DocumentNotFoundError} when
155
+ * Remove the document at `locator.path`. Rejects with a {@link DocumentNotFoundError} when
136
156
  * there is no document there, and with anything else when the backend could
137
157
  * not be asked — a caller must not read the second as the first and report
138
158
  * the document gone.
@@ -140,8 +160,21 @@ export interface DocumentStorage {
140
160
  deleteDocument(locator: DocumentLocator): Promise<void>;
141
161
 
142
162
  /**
143
- * Rename or relocate a document, keeping its content. Rejects with a
144
- * {@link DocumentNotFoundError} when `from` is missing.
163
+ * Rename or relocate a document, keeping its content, and record `to.type`
164
+ * as its layout. Rejects with a {@link DocumentNotFoundError} when nothing
165
+ * is at `from.path`.
145
166
  */
146
167
  moveDocument(from: DocumentLocator, to: DocumentLocator): Promise<void>;
168
+
169
+ /**
170
+ * Optional. The package-relative path at which {@link saveDocument} will
171
+ * put the file for `locator`, for a store that files a document somewhere
172
+ * other than the package path the SDK asked for (one that files a report
173
+ * by its layout, say). `createDocument` asks before it renders a new
174
+ * report, so the report's imports are written relative to
175
+ * where the file really lands, and returns that path as the report's
176
+ * `path`. Left out, the SDK assumes the requested package path: the
177
+ * locator's `path` minus its `<environment>/<package>/` prefix.
178
+ */
179
+ resolveDocumentPath?(locator: DocumentLocator): string | Promise<string>;
147
180
  }
@@ -97,7 +97,7 @@ export default function AddEnvironmentDialog() {
97
97
  id="description"
98
98
  name="description"
99
99
  label="Description"
100
- placeholder="Explore semantic models, run queries, and build dashboards"
100
+ placeholder="Explore semantic models, run queries, and build reports"
101
101
  type="text"
102
102
  fullWidth
103
103
  size="small"
@@ -52,7 +52,7 @@ const FEATURES: Array<{ title: string; body: string; href: string }> = [
52
52
  },
53
53
  {
54
54
  title: "Surface",
55
- body: "Dashboards declared in Malloy, notebooks, and no-build HTML data apps, all shipped inside the package, plus this Console for browsing them.",
55
+ body: "Reports declared in Malloy, laid out as a grid or read top to bottom, and no-build HTML data apps, all shipped inside the package, plus this Console for browsing them.",
56
56
  href: DOC_LINKS.surfaces,
57
57
  },
58
58
  {
@@ -9,7 +9,7 @@ import { Box, CircularProgress, Typography } from "@mui/material";
9
9
  * document rather than a mix of "Fetching", "Loading" and "Opening".
10
10
  */
11
11
  export const LOADING_COPY = {
12
- /** A document being fetched: "Opening the dashboard…", or "Opening…". */
12
+ /** A document being fetched: "Opening the report…", or "Opening…". */
13
13
  opening: (noun?: string) => (noun ? `Opening the ${noun}…` : "Opening…"),
14
14
  /** A query on its way to a result. */
15
15
  running: "Running…",
@@ -12,7 +12,7 @@ import {
12
12
 
13
13
  import React, { useEffect, useState } from "react";
14
14
  import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
15
- import { loadQueryBuilder } from "../DashboardBuilder/loadMalloy";
15
+ import { loadQueryBuilder } from "../ReportBuilder/loadMalloy";
16
16
  import { parseResourceUri } from "../../utils/formatting";
17
17
  // import { ApiErrorDisplay } from "../ApiErrorDisplay";
18
18
  import { useServer } from "../ServerProvider";
@@ -130,10 +130,11 @@ export function NotebookCell({
130
130
  // by that dimension is clickable for free: the same resolution, and the
131
131
  // same hook, the dashboard viewer uses.
132
132
  const { drill, drillMenu } = useDrill({
133
- // The dashboards route now exists, so a `# drill { to=<dashboard> }` from
134
- // a notebook cell is honoured: the host turns the destination and its
135
- // seeded givens into `/{env}/{pkg}/dashboards/<slug>?GIVEN=value`. Passed
136
- // through rather than built here, because only the host knows its routing.
133
+ // A `# drill { to=<report> }` from a cell is honoured: the host resolves
134
+ // the destination (a package path from the root) and turns it and its
135
+ // seeded givens into the report's route, the Console's being
136
+ // `/{env}/{pkg}/<path>?GIVEN=value`. Passed through rather than built
137
+ // here, because only the host knows its routing.
137
138
  //
138
139
  // Still optional, and the reason matters: a host without a dashboard
139
140
  // route omits it, which makes a named destination non-honorable and
@@ -153,7 +154,7 @@ export function NotebookCell({
153
154
  canSelf: canDrillSelf,
154
155
  // The reader is in a notebook, so `to=self` says so: the drill tag is on
155
156
  // a shared model dimension and cannot know which document it fired in.
156
- selfLabel: "Filter this notebook",
157
+ selfLabel: "Filter this report",
157
158
  });
158
159
  // Regex to extract imported names from import statements
159
160
  const IMPORT_NAMES_REGEX = /import\s*\{([^}]+)\}\s*from\s*['"`][^'"`]+['"`]/;
@@ -10,9 +10,13 @@ import {
10
10
  } from "./cellKind";
11
11
 
12
12
  describe("cellRuns", () => {
13
- it("runs a .malloynb code cell and skips its markdown", () => {
14
- expect(cellRuns({ type: "code" })).toBe(true);
15
- expect(cellRuns({ type: "markdown" })).toBe(false);
13
+ // DEPRECATED FEATURE COVERAGE — delete together with
14
+ // `.malloynb` notebooks (see RELEASE_NOTES deprecations).
15
+ describe("deprecated: .malloynb notebooks", () => {
16
+ it("runs a .malloynb code cell and skips its markdown", () => {
17
+ expect(cellRuns({ type: "code" })).toBe(true);
18
+ expect(cellRuns({ type: "markdown" })).toBe(false);
19
+ });
16
20
  });
17
21
 
18
22
  it("runs only a query cell of a served notebook", () => {
@@ -142,10 +146,14 @@ describe("stripProse", () => {
142
146
  ).toBe("run: q\n#(markdown) x");
143
147
  });
144
148
 
145
- it("without ranges, drops a .malloynb ##! line exactly as the released code did", () => {
146
- expect(stripProse({ text: "##! experimental.parameters\nrun: q" })).toBe(
147
- "run: q",
148
- );
149
+ // DEPRECATED FEATURE COVERAGE — delete together with
150
+ // `.malloynb` notebooks (see RELEASE_NOTES deprecations).
151
+ describe("deprecated: .malloynb notebooks", () => {
152
+ it("without ranges, drops a .malloynb ##! line exactly as the released code did", () => {
153
+ expect(
154
+ stripProse({ text: "##! experimental.parameters\nrun: q" }),
155
+ ).toBe("run: q");
156
+ });
149
157
  });
150
158
 
151
159
  it("without ranges, leaves (markdown) lines alone", () => {