@malloy-publisher/sdk 0.9.6 → 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.
- package/README.md +117 -17
- package/dist/{RenderedResult-qnpbr4tc.cjs.js → RenderedResult-BrvrMDAP.cjs.js} +1 -1
- package/dist/{RenderedResult-BUb2Xvr2.es.js → RenderedResult-DZj-FnOJ.es.js} +2 -2
- package/dist/{ServerProvider-C6QQVKPm.es.js → ServerProvider-B_bPAsu2.es.js} +595 -410
- package/dist/ServerProvider-DuEOzwPc.cjs.js +1 -0
- package/dist/builder/index.cjs.js +93 -93
- package/dist/builder/index.es.js +4630 -4562
- package/dist/builder-entry.d.ts +13 -12
- package/dist/client/api.d.ts +489 -111
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +105 -95
- package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
- package/dist/components/Dashboard/DashboardView.d.ts +1 -3
- package/dist/components/Dashboard/index.d.ts +0 -2
- package/dist/components/DocumentCreate/createDocument.d.ts +29 -9
- package/dist/components/DocumentCreate/documentPath.d.ts +21 -6
- package/dist/components/DocumentCreate/guards.d.ts +2 -3
- package/dist/components/DocumentCreate/index.d.ts +2 -3
- package/dist/components/DocumentCreate/newNotebook.d.ts +14 -5
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +6 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +52 -24
- package/dist/components/Loading.d.ts +1 -1
- package/dist/components/Package/DataSchemaDialog.d.ts +26 -0
- package/dist/components/Package/NewDocumentDialog.d.ts +19 -10
- package/dist/components/Package/Package.d.ts +14 -9
- package/dist/components/Package/documentLocation.d.ts +66 -23
- package/dist/components/Package/index.d.ts +3 -2
- package/dist/components/Package/reportQueries.d.ts +8 -0
- package/dist/components/Package/useDocumentLocation.d.ts +36 -6
- package/dist/components/Package/useDraftLayout.d.ts +20 -0
- package/dist/components/Report/CellReport.d.ts +89 -0
- package/dist/components/Report/LinearReport.d.ts +18 -0
- package/dist/components/Report/Report.d.ts +62 -0
- package/dist/components/Report/index.d.ts +2 -0
- package/dist/components/Report/telemetry.d.ts +163 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.d.ts +5 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/EditorSurface.d.ts +10 -7
- package/dist/components/{DashboardBuilder/DashboardBuilder.d.ts → ReportBuilder/ReportBuilder.d.ts} +17 -8
- package/dist/components/{DashboardBuilder/DashboardEditor.d.ts → ReportBuilder/ReportEditor.d.ts} +41 -14
- package/dist/components/ReportBuilder/builderReport.d.ts +14 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/catalog.d.ts +8 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/document.d.ts +3 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/documentSession.d.ts +1 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/imports.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/malloyTree.d.ts +9 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/newDashboard.d.ts +7 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/readDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/readForEditor.d.ts +1 -1
- package/dist/components/ReportBuilder/reportTag.d.ts +52 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/spliceDocument.d.ts +1 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/useControlBindings.d.ts +2 -2
- package/dist/components/ReportBuilder/useEditorCatalog.d.ts +25 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/useHostCopy.d.ts +5 -3
- package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder/useDashboardEditor.d.ts → ReportBuilder/useReportEditor.d.ts} +3 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.d.ts +6 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/useTileEditing.d.ts +2 -2
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +8 -1
- package/dist/components/drill/useDrillSelf.d.ts +4 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/{Dashboard → legacy}/Dashboard.d.ts +15 -9
- package/dist/components/legacy/MalloynbCells.d.ts +13 -0
- package/dist/components/legacy/Notebook.d.ts +15 -0
- package/dist/components/{DashboardBuilder → legacy}/NotebookEditor.d.ts +3 -3
- package/dist/components/legacy/builderNames.d.ts +10 -0
- package/dist/components/legacy/index.d.ts +11 -0
- package/dist/components/legacy/kindAdapter.d.ts +11 -0
- package/dist/components/legacy/kindTypedDrafts.d.ts +10 -0
- package/dist/components/legacy/nameAlias.d.ts +44 -0
- package/dist/components/legacy/queryKeys.d.ts +8 -0
- package/dist/index.cjs.js +19 -19
- package/dist/index.es.js +7984 -7452
- package/dist/text/index.es.js +2 -2
- package/dist/{text-entry-CA0LZ1xL.es.js → text-entry-72YFLeNk.es.js} +10 -10
- package/dist/useCompiledDocument-oocN5cGE.cjs.js +141 -0
- package/dist/{useCompiledDocument-0sxonf6N.es.js → useCompiledDocument-x0B2RAH3.es.js} +4593 -4395
- package/package.json +2 -2
- package/src/builder-entry.ts +32 -24
- package/src/components/Dashboard/DashboardTile.tsx +17 -0
- package/src/components/Dashboard/DashboardView.spec.tsx +0 -21
- package/src/components/Dashboard/DashboardView.tsx +8 -24
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +1 -4
- package/src/components/Dashboard/index.ts +0 -2
- package/src/components/DocumentCreate/createDocument.spec.ts +346 -53
- package/src/components/DocumentCreate/createDocument.ts +143 -63
- package/src/components/DocumentCreate/documentPath.ts +41 -12
- package/src/components/DocumentCreate/guards.ts +7 -15
- package/src/components/DocumentCreate/index.ts +3 -7
- package/src/components/DocumentCreate/newNotebook.spec.ts +113 -43
- package/src/components/DocumentCreate/newNotebook.ts +32 -10
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +130 -28
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +78 -40
- package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +426 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +57 -24
- package/src/components/Home/AddEnvironmentDialog.tsx +1 -1
- package/src/components/Home/Home.tsx +1 -1
- package/src/components/Loading.tsx +1 -1
- package/src/components/Model/SourcesExplorer.tsx +1 -1
- package/src/components/Notebook/NotebookCell.tsx +6 -5
- package/src/components/Notebook/cellKind.spec.ts +15 -7
- package/src/components/Package/DataSchemaDialog.spec.tsx +85 -0
- package/src/components/Package/DataSchemaDialog.tsx +367 -0
- package/src/components/Package/NewDocumentDialog.spec.tsx +145 -88
- package/src/components/Package/NewDocumentDialog.tsx +93 -48
- package/src/components/Package/Package.artifacts.spec.tsx +79 -60
- package/src/components/Package/Package.create.spec.tsx +126 -112
- package/src/components/Package/Package.notebooks.spec.tsx +46 -27
- package/src/components/Package/Package.spec.tsx +43 -30
- package/src/components/Package/Package.tsx +173 -292
- package/src/components/Package/documentLocation.spec.ts +145 -50
- package/src/components/Package/documentLocation.ts +118 -39
- package/src/components/Package/index.ts +12 -3
- package/src/components/Package/reportQueries.ts +25 -0
- package/src/components/Package/useDocumentLocation.spec.ts +58 -0
- package/src/components/Package/useDocumentLocation.ts +90 -32
- package/src/components/Package/useDraftLayout.spec.tsx +143 -0
- package/src/components/Package/useDraftLayout.ts +81 -0
- package/src/components/Prose.spec.tsx +3 -3
- package/src/components/RenderedResult/RenderedResult.tsx +1 -1
- package/src/components/Report/CellReport.spec.tsx +155 -0
- package/src/components/{Notebook/Notebook.tsx → Report/CellReport.tsx} +178 -220
- package/src/components/Report/LinearReport.tsx +71 -0
- package/src/components/Report/Report.spec.tsx +238 -0
- package/src/components/Report/Report.telemetry.spec.tsx +292 -0
- package/src/components/Report/Report.tsx +277 -0
- package/src/components/Report/index.ts +12 -0
- package/src/components/Report/telemetry.spec.ts +90 -0
- package/src/components/Report/telemetry.ts +250 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.tsx +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.tsx +6 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.tsx +33 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/DrillDialog.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/EditorSurface.tsx +67 -107
- package/src/components/{DashboardBuilder → ReportBuilder}/FilterDialog.tsx +3 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.charts.spec.tsx → ReportBuilder/ReportBuilder.charts.spec.tsx} +4 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.exit.spec.tsx → ReportBuilder/ReportBuilder.exit.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.inline.spec.tsx → ReportBuilder/ReportBuilder.inline.spec.tsx} +4 -4
- package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +145 -0
- package/src/components/{DashboardBuilder/DashboardBuilder.notebook.spec.tsx → ReportBuilder/ReportBuilder.notebook.spec.tsx} +22 -21
- package/src/components/{DashboardBuilder/DashboardBuilder.openDraft.spec.tsx → ReportBuilder/ReportBuilder.openDraft.spec.tsx} +3 -3
- package/src/components/{DashboardBuilder/DashboardBuilder.sources.spec.tsx → ReportBuilder/ReportBuilder.sources.spec.tsx} +19 -8
- package/src/components/{DashboardBuilder/DashboardBuilder.spec.tsx → ReportBuilder/ReportBuilder.spec.tsx} +34 -34
- package/src/components/{DashboardBuilder/DashboardBuilder.textTiles.spec.tsx → ReportBuilder/ReportBuilder.textTiles.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.tsx → ReportBuilder/ReportBuilder.tsx} +46 -21
- package/src/components/{DashboardBuilder/DashboardEditor.authoritative.spec.tsx → ReportBuilder/ReportEditor.authoritative.spec.tsx} +28 -20
- package/src/components/{DashboardBuilder/DashboardEditor.emptyStart.spec.tsx → ReportBuilder/ReportEditor.emptyStart.spec.tsx} +19 -11
- package/src/components/{DashboardBuilder/DashboardEditor.filterTag.spec.tsx → ReportBuilder/ReportEditor.filterTag.spec.tsx} +7 -7
- package/src/components/{DashboardBuilder/DashboardEditor.notebook.spec.tsx → ReportBuilder/ReportEditor.notebook.spec.tsx} +70 -49
- package/src/components/{DashboardBuilder/DashboardEditor.package.spec.tsx → ReportBuilder/ReportEditor.package.spec.tsx} +52 -8
- package/src/components/{DashboardBuilder/DashboardEditor.resourceUri.spec.tsx → ReportBuilder/ReportEditor.resourceUri.spec.tsx} +50 -18
- package/src/components/{DashboardBuilder/DashboardEditor.spec.tsx → ReportBuilder/ReportEditor.spec.tsx} +65 -20
- package/src/components/{DashboardBuilder/DashboardEditor.textSource.spec.tsx → ReportBuilder/ReportEditor.textSource.spec.tsx} +6 -6
- package/src/components/{DashboardBuilder/DashboardEditor.tsx → ReportBuilder/ReportEditor.tsx} +92 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/addTile.compile.spec.ts +6 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/artifactBlock.spec.ts +21 -29
- package/src/components/ReportBuilder/builderReport.ts +53 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.spec.ts +28 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.ts +17 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/controls.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/document.ts +4 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.spec.ts +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.spec.ts +6 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.ts +8 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.chart.spec.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.convert.spec.ts +9 -13
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.read.spec.ts +15 -15
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.ts +7 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.ts +25 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.spec.ts +12 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.ts +11 -24
- package/src/components/{DashboardBuilder → ReportBuilder}/preview.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.spec.ts +64 -36
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.ts +33 -32
- package/src/components/ReportBuilder/readForEditor.spec.ts +96 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readForEditor.ts +3 -11
- package/src/components/ReportBuilder/reportTag.ts +108 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.imports.spec.ts +28 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.spec.ts +32 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.ts +37 -60
- package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.spec.ts +3 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/testing/artifactTagParity.json +2 -2
- package/src/components/ReportBuilder/testing/drillResolution.json +279 -0
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +125 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/textTiles.spec.ts +66 -143
- package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.ts +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/useControlBindings.ts +2 -2
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +156 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +119 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/useHostCopy.ts +7 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.ts +56 -35
- package/src/components/{DashboardBuilder/useDashboardEditor.spec.ts → ReportBuilder/useReportEditor.spec.ts} +6 -6
- package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts} +6 -17
- package/src/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.ts +36 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/useTileEditing.ts +2 -2
- package/src/components/ServerProvider.tsx +2 -0
- package/src/components/drill/resolveDrill.ts +9 -2
- package/src/components/drill/useDrill.tsx +1 -0
- package/src/components/drill/useDrillSelf.spec.tsx +60 -7
- package/src/components/drill/useDrillSelf.ts +29 -12
- package/src/components/index.ts +2 -1
- package/src/components/{Dashboard → legacy}/Dashboard.spec.tsx +1 -1
- package/src/components/{Dashboard → legacy}/Dashboard.tsx +40 -28
- package/src/components/legacy/MalloynbCells.tsx +88 -0
- package/src/components/{Notebook → legacy}/Notebook.served.spec.tsx +17 -13
- package/src/components/{Notebook → legacy}/Notebook.spec.tsx +24 -20
- package/src/components/legacy/Notebook.tsx +44 -0
- package/src/components/{DashboardBuilder → legacy}/NotebookEditor.tsx +7 -4
- package/src/components/legacy/builderNames.ts +25 -0
- package/src/components/legacy/index.ts +20 -0
- package/src/components/legacy/kindAdapter.ts +19 -0
- package/src/components/legacy/kindTypedDrafts.ts +34 -0
- package/src/components/legacy/nameAlias.spec.ts +124 -0
- package/src/components/legacy/nameAlias.ts +95 -0
- package/src/components/legacy/queryKeys.ts +26 -0
- package/src/hooks/useGivensState.spec.ts +9 -9
- package/src/mainEntry.spec.ts +1 -1
- package/src/textEntry.spec.ts +9 -9
- package/src/utils/formatting.spec.ts +5 -5
- package/src/utils/parsing.spec.ts +1 -1
- package/src/utils/parsing.ts +1 -1
- package/dist/ServerProvider-Gj-im5VD.cjs.js +0 -1
- package/dist/components/Dashboard/telemetry.d.ts +0 -73
- package/dist/components/DashboardBuilder/builderReport.d.ts +0 -13
- package/dist/components/DashboardBuilder/telemetry.d.ts +0 -43
- package/dist/components/DocumentCreate/events.d.ts +0 -10
- package/dist/components/Notebook/Notebook.d.ts +0 -52
- package/dist/components/Notebook/index.d.ts +0 -1
- package/dist/useCompiledDocument-tBejqZ7s.cjs.js +0 -142
- package/src/components/Dashboard/telemetry.ts +0 -75
- package/src/components/DashboardBuilder/builderReport.ts +0 -74
- package/src/components/DashboardBuilder/readForEditor.spec.ts +0 -80
- package/src/components/DashboardBuilder/telemetry.ts +0 -47
- package/src/components/DashboardBuilder/testing/documentKindRule.json +0 -40
- package/src/components/DocumentCreate/events.ts +0 -15
- package/src/components/Notebook/index.ts +0 -4
- /package/dist/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/ChartPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/DrillDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterStrip.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TextTileBody.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileFrame.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileMenu.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/annotationText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/changedTile.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/chartLine.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/controls.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/inlineEdit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/layout.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/loadMalloy.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/openDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/preview.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/sortable.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/spliceResult.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tagParse.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/inline.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/resize.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useExitGuard.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useFilterForm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileReorder.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileResize.d.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.render.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/FilterStrip.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineText.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TextTileBody.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileFrame.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileMenu.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/__test__/inventory.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/artifactTagParity.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/catalog.aggregate.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/controls.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/emptyStart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/inlineEdit.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/invariants.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/keepRowStructure.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/layout.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/moveIntoGap.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/openDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.shapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/scannerShapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.chart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceResult.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/statementExtent.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/inline.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/resize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/urlRenderTags.json +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.overlay.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.existing.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/withGaps.spec.ts +0 -0
- /package/src/components/{Notebook → legacy}/Notebook.layout.spec.tsx +0 -0
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { annotationTextProblem } from "./annotationText";
|
|
5
5
|
import { isBareName } from "../../utils/malloyText";
|
|
6
|
+
import { newReportSource } from "../DocumentCreate/newNotebook";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* A new dashboard file, the way the builder would have written it: the
|
|
@@ -46,30 +47,16 @@ export function newDashboardProblem({
|
|
|
46
47
|
return annotationTextProblem("title", title);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
/**
|
|
51
|
+
* A new grid report; see `newReportSource`, which writes both layouts from
|
|
52
|
+
* one template.
|
|
53
|
+
*/
|
|
54
|
+
export function newDashboardSource(
|
|
55
|
+
dashboard: NewDashboard,
|
|
56
|
+
/** The package path the report is written at; the import is relative to it. Default: the root. */
|
|
57
|
+
reportPath?: string,
|
|
58
|
+
): string {
|
|
50
59
|
const problem = newDashboardProblem(dashboard);
|
|
51
60
|
if (problem) throw new Error(problem);
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function writeNewDashboard({
|
|
56
|
-
title,
|
|
57
|
-
modelPath,
|
|
58
|
-
source,
|
|
59
|
-
view,
|
|
60
|
-
}: NewDashboard): string {
|
|
61
|
-
const extension = `${source}_tiles`;
|
|
62
|
-
const tile = `${view}_tile`;
|
|
63
|
-
const quoted = `"${title.trim().replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
64
|
-
return [
|
|
65
|
-
"##! experimental.givens",
|
|
66
|
-
`## artifact { title=${quoted} tiles=["${extension} -> ${tile}"] } dashboard { columns=12 }`,
|
|
67
|
-
`import { ${source} } from "../${modelPath}"`,
|
|
68
|
-
"",
|
|
69
|
-
`source: ${extension} is ${source} extend {`,
|
|
70
|
-
" # colspan=6",
|
|
71
|
-
` view: ${tile} is ${view}`,
|
|
72
|
-
"}",
|
|
73
|
-
"",
|
|
74
|
-
].join("\n");
|
|
61
|
+
return newReportSource(dashboard, "grid", reportPath);
|
|
75
62
|
}
|
|
@@ -7,6 +7,7 @@ import * as fs from "fs";
|
|
|
7
7
|
import * as path from "path";
|
|
8
8
|
import { blockAbove, readDashboardDocument, readFailed } from "./readDocument";
|
|
9
9
|
import { readForEditor } from "./readForEditor";
|
|
10
|
+
import { readReportTagOfText } from "./reportTag";
|
|
10
11
|
import { parseMalloy, parseRefused } from "./malloyTree";
|
|
11
12
|
import { queryTile } from "./testing/fixtures";
|
|
12
13
|
import { tileKey } from "./document";
|
|
@@ -798,7 +799,7 @@ describe("readDashboardDocument: what it refuses", () => {
|
|
|
798
799
|
it("refuses a file with no artifact tag", async () => {
|
|
799
800
|
const r = await readDashboardDocument("source: a is b extend { }");
|
|
800
801
|
expect(r.ok).toBe(false);
|
|
801
|
-
if (readFailed(r)) expect(r.reason).toContain("
|
|
802
|
+
if (readFailed(r)) expect(r.reason).toContain("not a report");
|
|
802
803
|
});
|
|
803
804
|
|
|
804
805
|
it("refuses a tile that is not a source -> view expression", async () => {
|
|
@@ -863,8 +864,7 @@ describe("a tag whose artifact property is not the first", () => {
|
|
|
863
864
|
|
|
864
865
|
it("is refused, not converted, for a cell-format notebook", async () => {
|
|
865
866
|
const open = await readForEditor(
|
|
866
|
-
`##! experimental.givens\n## dashboard { columns=2 } artifact {
|
|
867
|
-
"notebooks/n.malloy",
|
|
867
|
+
`##! experimental.givens\n## dashboard { columns=2 } artifact { layout=linear title="T" }\nrun: a -> by_cat`,
|
|
868
868
|
);
|
|
869
869
|
expect(open.ok === false && open.reason).toContain(
|
|
870
870
|
"`artifact { … }` first",
|
|
@@ -882,11 +882,11 @@ describe("a tag whose artifact property is not the first", () => {
|
|
|
882
882
|
|
|
883
883
|
/**
|
|
884
884
|
* The tripwire. All-or-nothing refusal is only reasonable while real dashboards
|
|
885
|
-
* open, so this asserts that every
|
|
885
|
+
* open, so this asserts that every not a report in the repository does.
|
|
886
886
|
* If that stops being true, this fails in CI rather than in a support thread,
|
|
887
887
|
* and it is the signal to reconsider opening files partially.
|
|
888
888
|
*/
|
|
889
|
-
describe("every
|
|
889
|
+
describe("every not a report in the repository opens", () => {
|
|
890
890
|
const roots = ["examples", "packages/server/tests/fixtures"];
|
|
891
891
|
const found: string[] = [];
|
|
892
892
|
const walk = (dir: string) => {
|
|
@@ -900,9 +900,15 @@ describe("every composite dashboard in the repository opens", () => {
|
|
|
900
900
|
};
|
|
901
901
|
for (const root of roots) walk(path.join(REPO, root));
|
|
902
902
|
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
)
|
|
903
|
+
// A report whose one tile is a named query is not one the builder lays
|
|
904
|
+
// out (it edits `source -> view` tiles), so it is not expected to open.
|
|
905
|
+
const composites = found.filter((f) => {
|
|
906
|
+
const text = fs.readFileSync(f, "utf8");
|
|
907
|
+
return (
|
|
908
|
+
/##\s*artifact[\s\S]*tiles\s*=/.test(text) &&
|
|
909
|
+
!/tiles=\["[A-Za-z_]\w*"\]/.test(text)
|
|
910
|
+
);
|
|
911
|
+
});
|
|
906
912
|
|
|
907
913
|
it("finds composites to check", () => {
|
|
908
914
|
expect(composites.length).toBeGreaterThan(0);
|
|
@@ -956,38 +962,60 @@ describe("the compiler stays lazy", () => {
|
|
|
956
962
|
});
|
|
957
963
|
});
|
|
958
964
|
|
|
959
|
-
describe("the
|
|
965
|
+
describe("the layout of a report", () => {
|
|
966
|
+
it("reads the same layout wherever the file lives: the folder no longer matters", async () => {
|
|
967
|
+
const cases = [
|
|
968
|
+
["## artifact { }\nrun: q -> { aggregate: c }\n", true],
|
|
969
|
+
[`## artifact { tiles=["a -> v"] }\n`, false],
|
|
970
|
+
[`## artifact { layout=linear tiles=["a -> v"] }\n`, true],
|
|
971
|
+
["## artifact { layout=grid tiles=[] }\n", false],
|
|
972
|
+
] as const;
|
|
973
|
+
for (const [source, linear] of cases)
|
|
974
|
+
for (const where of [
|
|
975
|
+
undefined,
|
|
976
|
+
"x.malloy",
|
|
977
|
+
"notebooks/x.malloy",
|
|
978
|
+
"dashboards/x.malloy",
|
|
979
|
+
"sales/q3/x.malloy",
|
|
980
|
+
]) {
|
|
981
|
+
const result = await readDashboardDocument(source, where);
|
|
982
|
+
const isLinear = readFailed(result)
|
|
983
|
+
? result.legacyNotebook === true
|
|
984
|
+
: result.document.layout === "linear";
|
|
985
|
+
expect([where, isLinear]).toEqual([where, linear]);
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* The layout parity table the server's one reader is held to
|
|
992
|
+
* (`report_layout_parity.spec.ts`): the SDK's tag reader gives the same
|
|
993
|
+
* answer on every case, and the builder opens a file it can open with that
|
|
994
|
+
* layout.
|
|
995
|
+
*/
|
|
996
|
+
describe("report layout parity: the SDK reader", () => {
|
|
960
997
|
const { cases } = JSON.parse(
|
|
961
998
|
fs.readFileSync(
|
|
962
|
-
path.join(import.meta.dir, "testing/
|
|
999
|
+
path.join(import.meta.dir, "testing/reportLayoutParity.json"),
|
|
963
1000
|
"utf8",
|
|
964
1001
|
),
|
|
965
|
-
) as {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1002
|
+
) as {
|
|
1003
|
+
cases: {
|
|
1004
|
+
name: string;
|
|
1005
|
+
source: string;
|
|
1006
|
+
expected: "grid" | "linear" | null;
|
|
1007
|
+
}[];
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
for (const testCase of cases) {
|
|
1011
|
+
it(testCase.name, async () => {
|
|
1012
|
+
const tag = await readReportTagOfText(testCase.source);
|
|
1013
|
+
expect(tag.status === "report" ? tag.layout : null).toBe(
|
|
1014
|
+
testCase.expected,
|
|
1015
|
+
);
|
|
1016
|
+
const read = await readDashboardDocument(testCase.source);
|
|
1017
|
+
if (!readFailed(read))
|
|
1018
|
+
expect(read.document.layout).toBe(testCase.expected);
|
|
975
1019
|
});
|
|
976
1020
|
}
|
|
977
|
-
|
|
978
|
-
it("still takes the folder's kind when the host has a folder", async () => {
|
|
979
|
-
const source = "## artifact { }\nrun: q -> { aggregate: c }\n";
|
|
980
|
-
const inNotebooks = await readDashboardDocument(
|
|
981
|
-
source,
|
|
982
|
-
"notebooks/x.malloy",
|
|
983
|
-
);
|
|
984
|
-
expect(readFailed(inNotebooks) && inNotebooks.legacyNotebook).toBe(true);
|
|
985
|
-
const inDashboards = await readDashboardDocument(
|
|
986
|
-
source,
|
|
987
|
-
"dashboards/x.malloy",
|
|
988
|
-
);
|
|
989
|
-
expect(
|
|
990
|
-
readFailed(inDashboards) && inDashboards.legacyNotebook,
|
|
991
|
-
).toBeFalsy();
|
|
992
|
-
});
|
|
993
1021
|
});
|
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
} from "./document";
|
|
17
17
|
import { isTextTile } from "./document";
|
|
18
18
|
import { loadMalloyTag } from "./loadMalloy";
|
|
19
|
+
import { kindRemovedReason, readReportTag } from "./reportTag";
|
|
19
20
|
import { parseTagLines } from "./tagParse";
|
|
20
21
|
import {
|
|
21
22
|
parseMalloy,
|
|
@@ -37,7 +38,7 @@ import {
|
|
|
37
38
|
} from "../../utils/malloyText";
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
* Read a
|
|
41
|
+
* Read a report file (either layout, anywhere in the package) into a {@link DashboardDocument}.
|
|
41
42
|
*
|
|
42
43
|
* PURE: source text in, document out. No server, no schema, no connection.
|
|
43
44
|
* `Malloy.parse` needs none of those — only `Malloy.compile` does — so this runs
|
|
@@ -66,7 +67,7 @@ export interface ReadFailure {
|
|
|
66
67
|
reason: string;
|
|
67
68
|
/** 1-based, for a message that can point at the line. */
|
|
68
69
|
line?: number;
|
|
69
|
-
/** The file is a
|
|
70
|
+
/** The file is a linear report in the run-cell format, which `convertLegacyNotebook` turns into a tile layout. */
|
|
70
71
|
legacyNotebook?: true;
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -161,9 +162,8 @@ function chartField(tags: Array<{ text: string }>): {
|
|
|
161
162
|
* is exactly `field <op> $GIVEN`.
|
|
162
163
|
*
|
|
163
164
|
* A clause that is anything else — a compound predicate, a literal comparison
|
|
164
|
-
* — is not a binding and is left exactly as written.
|
|
165
|
-
*
|
|
166
|
-
* the shapes that defeated them.
|
|
165
|
+
* — is not a binding and is left exactly as written. The test is structural,
|
|
166
|
+
* read off the tree, not a text heuristic.
|
|
167
167
|
*/
|
|
168
168
|
function filtersOf(
|
|
169
169
|
stage: TreeStage | undefined,
|
|
@@ -281,12 +281,13 @@ const TEXT_ENTRY = /^([A-Za-z_][A-Za-z0-9_]*)\s*\{/;
|
|
|
281
281
|
/** Refuses rather than throws: `Tag.text()` throws on a malformed date literal such as `@2024-13-01`, and dropping the value would lose it on the next save. */
|
|
282
282
|
export async function readDashboardDocument(
|
|
283
283
|
sourceText: string,
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
284
|
+
/** The file's path. Kept for callers; where a report lives never decides its layout. */
|
|
285
|
+
_modelPath?: string,
|
|
286
|
+
/** Kept for callers: text held by a host is read by the same rule as a file. */
|
|
287
|
+
_textHeld = false,
|
|
287
288
|
): Promise<ReadResult> {
|
|
288
289
|
try {
|
|
289
|
-
return await readDocumentText(sourceText
|
|
290
|
+
return await readDocumentText(sourceText);
|
|
290
291
|
} catch (error) {
|
|
291
292
|
return {
|
|
292
293
|
ok: false,
|
|
@@ -295,11 +296,7 @@ export async function readDashboardDocument(
|
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
async function readDocumentText(
|
|
299
|
-
sourceText: string,
|
|
300
|
-
modelPath: string | undefined,
|
|
301
|
-
textHeld: boolean,
|
|
302
|
-
): Promise<ReadResult> {
|
|
299
|
+
async function readDocumentText(sourceText: string): Promise<ReadResult> {
|
|
303
300
|
const { parseAnnotation } = await loadMalloyTag();
|
|
304
301
|
const lines = splitSourceLines(sourceText);
|
|
305
302
|
|
|
@@ -313,14 +310,28 @@ async function readDocumentText(
|
|
|
313
310
|
const parsed = parse.parsed;
|
|
314
311
|
|
|
315
312
|
const description = descriptionNotes(lines).text;
|
|
313
|
+
// What the file is, by the server's rule over the same model-level notes.
|
|
314
|
+
const reportTag = readReportTag(parsed.modelNotes, parseAnnotation as never);
|
|
315
|
+
if (reportTag.status === "none")
|
|
316
|
+
return {
|
|
317
|
+
ok: false,
|
|
318
|
+
reason: "No `## artifact { … }` tag, so this file is not a report.",
|
|
319
|
+
};
|
|
320
|
+
if (reportTag.status === "unparsed")
|
|
321
|
+
return {
|
|
322
|
+
ok: false,
|
|
323
|
+
reason: `The \`## artifact\` tag does not parse${reportTag.errors[0] ? `: ${reportTag.errors[0]}` : "."}`,
|
|
324
|
+
};
|
|
325
|
+
if (reportTag.status === "kind-removed")
|
|
326
|
+
return { ok: false, reason: kindRemovedReason(reportTag.kind) };
|
|
327
|
+
const layout = reportTag.layout;
|
|
328
|
+
|
|
316
329
|
const artifactAt = locateArtifactTag(lines);
|
|
317
|
-
if (artifactAt === undefined)
|
|
330
|
+
if (artifactAt === undefined)
|
|
318
331
|
return {
|
|
319
332
|
ok: false,
|
|
320
|
-
reason:
|
|
321
|
-
"No `## artifact { … }` tag, so this file is not a composite dashboard.",
|
|
333
|
+
reason: "No `## artifact { … }` tag, so this file is not a report.",
|
|
322
334
|
};
|
|
323
|
-
}
|
|
324
335
|
if (!artifactLeads(artifactAt.text))
|
|
325
336
|
return {
|
|
326
337
|
ok: false,
|
|
@@ -332,16 +343,6 @@ async function readDocumentText(
|
|
|
332
343
|
tagAnnotation(artifactAt.text),
|
|
333
344
|
]);
|
|
334
345
|
const artifactTag = tag?.tag("artifact");
|
|
335
|
-
const tagKind = artifactTag?.text("kind");
|
|
336
|
-
// The server's rule: a tag that names no kind takes the folder's, and submitted text has none, so tiles or a grid width make it a dashboard.
|
|
337
|
-
const listsLayout =
|
|
338
|
-
artifactTag?.has("tiles") === true || tag?.tag("dashboard") !== undefined;
|
|
339
|
-
const kind =
|
|
340
|
-
tagKind === "notebook" ||
|
|
341
|
-
(tagKind !== "dashboard" &&
|
|
342
|
-
(textHeld ? !listsLayout : modelPath?.startsWith("notebooks/")))
|
|
343
|
-
? ("notebook" as const)
|
|
344
|
-
: undefined;
|
|
345
346
|
const list = readTileList(artifactAt.text);
|
|
346
347
|
if (list === undefined) {
|
|
347
348
|
if (tagErrors.length > 0)
|
|
@@ -349,13 +350,13 @@ async function readDocumentText(
|
|
|
349
350
|
ok: false,
|
|
350
351
|
reason: `The \`## artifact\` tag does not parse: ${tagErrors[0]}`,
|
|
351
352
|
};
|
|
352
|
-
// A
|
|
353
|
-
if (
|
|
353
|
+
// A linear report is told from a tile layout by whether it lists tiles at all.
|
|
354
|
+
if (layout === "linear")
|
|
354
355
|
return {
|
|
355
356
|
ok: false,
|
|
356
357
|
legacyNotebook: true,
|
|
357
358
|
reason:
|
|
358
|
-
"This
|
|
359
|
+
"This report is in the cell format, with no `tiles=[…]` list.",
|
|
359
360
|
};
|
|
360
361
|
return {
|
|
361
362
|
ok: false,
|
|
@@ -558,7 +559,7 @@ async function readDocumentText(
|
|
|
558
559
|
return {
|
|
559
560
|
ok: true,
|
|
560
561
|
document: {
|
|
561
|
-
|
|
562
|
+
layout,
|
|
562
563
|
title: artifactTag?.text("title") ?? "",
|
|
563
564
|
...(description ? { description } : {}),
|
|
564
565
|
...(columnsTag === undefined ? {} : { columns: columnsTag }),
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import * as path from "path";
|
|
7
|
+
import { readForEditor } from "./readForEditor";
|
|
8
|
+
|
|
9
|
+
const REPO = path.resolve(import.meta.dir, "../../../../..");
|
|
10
|
+
const LEGACY = fs
|
|
11
|
+
.readFileSync(
|
|
12
|
+
path.join(REPO, "examples/storefront/category-review.malloy"),
|
|
13
|
+
"utf8",
|
|
14
|
+
)
|
|
15
|
+
.replace(/\r\n/g, "\n");
|
|
16
|
+
|
|
17
|
+
describe("readForEditor", () => {
|
|
18
|
+
it("opens a layout file as it is, with no conversion", async () => {
|
|
19
|
+
const result = await readForEditor(
|
|
20
|
+
`## artifact { title="D" tiles=["a -> x"] }\nsource: a is b extend {\n view: x is v\n}\n`,
|
|
21
|
+
);
|
|
22
|
+
expect(result.ok).toBe(true);
|
|
23
|
+
expect(result.ok && result.conversion).toBeUndefined();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("converts a cell-format notebook, keeping the disk text to hand back", async () => {
|
|
27
|
+
const result = await readForEditor(LEGACY);
|
|
28
|
+
if (result.ok === false) throw new Error(result.reason);
|
|
29
|
+
expect(result.conversion?.from).toBe(LEGACY);
|
|
30
|
+
expect(result.conversion?.to).toContain(
|
|
31
|
+
"tiles=[\n text_1 { kind=text }",
|
|
32
|
+
);
|
|
33
|
+
expect(result.document.layout).toBe("linear");
|
|
34
|
+
expect(result.document.tiles).toHaveLength(7);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("refuses a conversion it cannot make, naming the line", async () => {
|
|
38
|
+
const result = await readForEditor(
|
|
39
|
+
`## artifact { layout=linear }\nimport { o } from "../m.malloy"\n\nrun: o extend { dimension: z is 1 } -> { select: z }\n`,
|
|
40
|
+
);
|
|
41
|
+
expect(result.ok).toBe(false);
|
|
42
|
+
expect(result.ok === false && result.reason).toMatch(/line 4/i);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("says why a file that is not a notebook will not open, with its line", async () => {
|
|
46
|
+
const result = await readForEditor(`source: a is b\n`);
|
|
47
|
+
expect(result.ok).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// The reader takes no path: a report's layout is its tag's, wherever it lives.
|
|
51
|
+
describe("a report's layout is its tags'", () => {
|
|
52
|
+
const LAYOUT = `## artifact { title="D" tiles=["a -> x"] }\nsource: a is b extend {\n view: x is v\n}\n`;
|
|
53
|
+
|
|
54
|
+
it("opens a tile list with no layout as a grid", async () => {
|
|
55
|
+
const result = await readForEditor(LAYOUT);
|
|
56
|
+
expect(result.ok && result.document.layout).toBe("grid");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("opens it linear when layout=linear says so", async () => {
|
|
60
|
+
const result = await readForEditor(
|
|
61
|
+
LAYOUT.replace("{ title", "{ layout=linear title"),
|
|
62
|
+
);
|
|
63
|
+
expect(result.ok && result.document.layout).toBe("linear");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("refuses a tag that sets the removed kind=, naming the layout= to write", async () => {
|
|
67
|
+
const result = await readForEditor(
|
|
68
|
+
LAYOUT.replace("{ title", "{ kind=notebook title"),
|
|
69
|
+
);
|
|
70
|
+
expect(result.ok).toBe(false);
|
|
71
|
+
expect(result.ok === false && result.reason).toContain(
|
|
72
|
+
"`kind=notebook` is no longer read",
|
|
73
|
+
);
|
|
74
|
+
expect(result.ok === false && result.reason).toContain(
|
|
75
|
+
"`layout=grid` or `layout=linear`",
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("converts a cell-format file with no layout rather than refusing it", async () => {
|
|
80
|
+
const layoutless = LEGACY.replace("layout=linear ", "");
|
|
81
|
+
expect(layoutless).not.toBe(LEGACY);
|
|
82
|
+
const result = await readForEditor(layoutless);
|
|
83
|
+
if (result.ok === false) throw new Error(result.reason);
|
|
84
|
+
expect(result.conversion?.from).toBe(layoutless);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// A tile list with no `layout=` reads as grid, so the converter writes `layout=linear`.
|
|
88
|
+
it("converts a cell-format file with no layout into a LINEAR report", async () => {
|
|
89
|
+
const layoutless = LEGACY.replace("layout=linear ", "");
|
|
90
|
+
const result = await readForEditor(layoutless);
|
|
91
|
+
if (result.ok === false) throw new Error(result.reason);
|
|
92
|
+
expect(result.document.layout).toBe("linear");
|
|
93
|
+
expect(result.conversion?.to).toContain("layout=linear");
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -21,12 +21,8 @@ const withLine = (reason: string, line: number | undefined) =>
|
|
|
21
21
|
: reason;
|
|
22
22
|
|
|
23
23
|
/** Read `text` for the builder, converting a cell-format notebook rather than refusing it. */
|
|
24
|
-
export async function readForEditor(
|
|
25
|
-
text
|
|
26
|
-
modelPath?: string,
|
|
27
|
-
textHeld = false,
|
|
28
|
-
): Promise<EditorOpen> {
|
|
29
|
-
const read = await readDashboardDocument(text, modelPath, textHeld);
|
|
24
|
+
export async function readForEditor(text: string): Promise<EditorOpen> {
|
|
25
|
+
const read = await readDashboardDocument(text);
|
|
30
26
|
if (!readFailed(read)) return { ok: true, document: read.document };
|
|
31
27
|
if (!read.legacyNotebook)
|
|
32
28
|
return { ok: false, reason: withLine(read.reason, read.line) };
|
|
@@ -34,11 +30,7 @@ export async function readForEditor(
|
|
|
34
30
|
const converted = await convertLegacyNotebook(text);
|
|
35
31
|
if (conversionRefused(converted))
|
|
36
32
|
return { ok: false, reason: withLine(converted.refused, converted.line) };
|
|
37
|
-
const reread = await readDashboardDocument(
|
|
38
|
-
converted.text,
|
|
39
|
-
modelPath,
|
|
40
|
-
textHeld,
|
|
41
|
-
);
|
|
33
|
+
const reread = await readDashboardDocument(converted.text);
|
|
42
34
|
if (readFailed(reread))
|
|
43
35
|
return {
|
|
44
36
|
ok: false,
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { setsArtifactProperty, tagAnnotation } from "../../utils/malloyText";
|
|
5
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
6
|
+
import { loadMalloyTag } from "./loadMalloy";
|
|
7
|
+
import {
|
|
8
|
+
isRule,
|
|
9
|
+
readModelNotes,
|
|
10
|
+
Reader,
|
|
11
|
+
translate,
|
|
12
|
+
type Ctx,
|
|
13
|
+
} from "./malloyTree";
|
|
14
|
+
import { parseTagLines } from "./tagParse";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* What a file's model-level notes make it, by the server's rule
|
|
18
|
+
* (`readReportTag`, `docs/reports-design.md` §1, §2):
|
|
19
|
+
*
|
|
20
|
+
* - `none`: no model-level `## artifact` note, so not a report.
|
|
21
|
+
* - `unparsed`: an artifact note the tag parser rejects, so not a report.
|
|
22
|
+
* - `kind-removed`: the tag sets the removed `kind=`, so not a report.
|
|
23
|
+
* - `report`: a report, with its layout.
|
|
24
|
+
*/
|
|
25
|
+
export type ReportTag =
|
|
26
|
+
| { status: "none" }
|
|
27
|
+
| { status: "unparsed"; errors: string[] }
|
|
28
|
+
| { status: "kind-removed"; kind: string }
|
|
29
|
+
| { status: "report"; layout: ReportLayout };
|
|
30
|
+
|
|
31
|
+
type Parsed = { tag: TagReads; log: Array<{ message: string }> };
|
|
32
|
+
type TagReads = {
|
|
33
|
+
tag(key: string): TagReads | undefined;
|
|
34
|
+
text(key: string): string | undefined;
|
|
35
|
+
has(key: string): boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** A tag property as text; `text()` throws on a malformed date literal, which reads as no value. */
|
|
39
|
+
const textOf = (tag: TagReads, key: string): string | undefined => {
|
|
40
|
+
try {
|
|
41
|
+
return tag.text(key);
|
|
42
|
+
} catch {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Malloy's route rule: a routed note (`##(markdown)`, `##"`) or a flag (`##!`) is never a tag. */
|
|
48
|
+
const onTagRoute = (note: string) => /^##\|?(?:[ \t\r\n]|$)/.test(note);
|
|
49
|
+
|
|
50
|
+
/** Why a `kind=` tag makes no report, and the fix: the server's message, word for word. */
|
|
51
|
+
export const kindRemovedReason = (kind: string) =>
|
|
52
|
+
`\`kind=${kind}\` is no longer read, so this file is not a report. Fix: remove \`kind=${kind}\` and write \`layout=grid\` or \`layout=linear\`.`;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The one reader of a report's tag in the SDK, over a file's model-level
|
|
56
|
+
* notes (`ParsedMalloy.modelNotes`). The server's `readReportTag` is the same
|
|
57
|
+
* rule over the same notes; `reportLayoutParity.json` holds the two together.
|
|
58
|
+
*
|
|
59
|
+
* The layout, first match wins: `layout=grid|linear`; else grid when the tag
|
|
60
|
+
* lists `tiles` (an empty list counts) or a model-level `dashboard { … }` grid
|
|
61
|
+
* tag is present; else linear.
|
|
62
|
+
*/
|
|
63
|
+
export function readReportTag(
|
|
64
|
+
modelNotes: readonly string[],
|
|
65
|
+
parseAnnotation: (lines: string[]) => Parsed,
|
|
66
|
+
): ReportTag {
|
|
67
|
+
// A note naming an environment value is dropped before parsing, as the server drops it.
|
|
68
|
+
const motly = modelNotes
|
|
69
|
+
.filter(onTagRoute)
|
|
70
|
+
.filter((note) => !note.includes("@env."))
|
|
71
|
+
.map(tagAnnotation);
|
|
72
|
+
const { tag, errors } =
|
|
73
|
+
motly.length > 0
|
|
74
|
+
? parseTagLines(parseAnnotation, motly)
|
|
75
|
+
: { tag: undefined, errors: [] };
|
|
76
|
+
const artifact = tag?.tag("artifact");
|
|
77
|
+
if (!artifact)
|
|
78
|
+
return modelNotes.some(setsArtifactProperty)
|
|
79
|
+
? { status: "unparsed", errors }
|
|
80
|
+
: { status: "none" };
|
|
81
|
+
const kind = textOf(artifact, "kind");
|
|
82
|
+
if (kind !== undefined) return { status: "kind-removed", kind };
|
|
83
|
+
const layout = textOf(artifact, "layout");
|
|
84
|
+
if (layout === "grid" || layout === "linear")
|
|
85
|
+
return { status: "report", layout };
|
|
86
|
+
if (artifact.has("tiles") || tag?.tag("dashboard") !== undefined)
|
|
87
|
+
return { status: "report", layout: "grid" };
|
|
88
|
+
return { status: "report", layout: "linear" };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* {@link readReportTag} over raw text, parsed for its notes and nothing else:
|
|
93
|
+
* the answer for a file whatever else is wrong with it, as the server reads a
|
|
94
|
+
* file that does not compile.
|
|
95
|
+
*/
|
|
96
|
+
export async function readReportTagOfText(text: string): Promise<ReportTag> {
|
|
97
|
+
const { parseAnnotation } = await loadMalloyTag();
|
|
98
|
+
let notes: string[] = [];
|
|
99
|
+
try {
|
|
100
|
+
const root = (await translate(text, "file://report.malloy")).parse
|
|
101
|
+
?.root as Ctx | undefined;
|
|
102
|
+
if (root && isRule(root) && typeof root.getChild === "function")
|
|
103
|
+
notes = readModelNotes(new Reader(text), root);
|
|
104
|
+
} catch {
|
|
105
|
+
notes = [];
|
|
106
|
+
}
|
|
107
|
+
return readReportTag(notes, parseAnnotation as never);
|
|
108
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { addTileToDocument } from "./addTileToDocument";
|
|
5
6
|
import { openDocument, refused, spliced } from "./testing/fixtures";
|
|
6
7
|
|
|
7
8
|
const SOURCE = `## artifact { title="Probe" tiles=["a -> by_cat"] } dashboard { columns=12 }
|
|
@@ -53,6 +54,32 @@ describe("spliceDashboardDocument: imports", () => {
|
|
|
53
54
|
});
|
|
54
55
|
});
|
|
55
56
|
|
|
57
|
+
it("puts a new import above a new extension when the file ends on its import", async () => {
|
|
58
|
+
const blank = `## artifact { title="Blank" tiles=[] }\nimport { orders } from '../orders.malloy'\n`;
|
|
59
|
+
const out = await spliced(blank, (d) => {
|
|
60
|
+
addTileToDocument(
|
|
61
|
+
d,
|
|
62
|
+
{
|
|
63
|
+
base: "recent_orders",
|
|
64
|
+
modelPath: "dashboards/_shared.malloy",
|
|
65
|
+
exporters: ["dashboards/_shared.malloy"],
|
|
66
|
+
view: "totals",
|
|
67
|
+
colspan: 6,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
modelPath: "dashboards/blank.malloy",
|
|
71
|
+
textHeld: false,
|
|
72
|
+
notebook: false,
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
const imported = out.indexOf(
|
|
77
|
+
'import { recent_orders } from "_shared.malloy"',
|
|
78
|
+
);
|
|
79
|
+
expect(imported).toBeGreaterThan(-1);
|
|
80
|
+
expect(imported).toBeLessThan(out.indexOf("source: recent_orders_tiles"));
|
|
81
|
+
});
|
|
82
|
+
|
|
56
83
|
it("takes a name off the statement", async () => {
|
|
57
84
|
const out = await spliced(SOURCE, (d) => {
|
|
58
85
|
const names = d.imports[1];
|
|
@@ -158,7 +185,7 @@ describe("spliceDashboardDocument: imports", () => {
|
|
|
158
185
|
});
|
|
159
186
|
|
|
160
187
|
it("has nowhere to put a first import", async () => {
|
|
161
|
-
const source = `## artifact {
|
|
188
|
+
const source = `## artifact { layout=linear title="T" tiles=[intro { kind=text }] }\n\n##|(markdown) intro\nHi\n|##\n`;
|
|
162
189
|
const reason = await refused(source, (d) => {
|
|
163
190
|
d.imports.push({ kind: "names", names: ["x"], from: "../m.malloy" });
|
|
164
191
|
});
|