@malloy-publisher/sdk 0.9.1 → 0.9.3
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/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-DwB0-9Yx.es.js} +219 -210
- package/dist/RenderedResult-hKjFEqaN.cjs.js +141 -0
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-CcSrGaRN.es.js} +1473 -1326
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +143 -58
- package/dist/builder/index.es.js +12179 -9318
- package/dist/builder-entry.d.ts +5 -1
- package/dist/client/api.d.ts +247 -56
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +94 -88
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +38 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +21 -2
- package/dist/components/Dashboard/DashboardView.d.ts +71 -0
- package/dist/components/Dashboard/TileCard.d.ts +30 -5
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +5 -1
- package/dist/components/Dashboard/telemetry.d.ts +16 -3
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +15 -9
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +23 -15
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +31 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +56 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +44 -5
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +8 -4
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +10 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +51 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +12 -6
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -18
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +6 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +16 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +15 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +86 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +19 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +6 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +17 -1
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +5 -1
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +3 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9041 -7002
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CA0LZ1xL.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{Dashboard-H1kJlDFo.es.js → useCompiledDocument-BU6d8FPp.es.js} +17904 -19057
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/dist/utils/clock.d.ts +2 -0
- package/dist/utils/malloyText.d.ts +104 -0
- package/package.json +20 -11
- package/src/builder-entry.ts +36 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +29 -280
- package/src/components/Dashboard/DashboardGrid.tsx +87 -8
- package/src/components/Dashboard/DashboardTile.spec.tsx +121 -2
- package/src/components/Dashboard/DashboardTile.tsx +121 -30
- package/src/components/Dashboard/DashboardView.spec.tsx +368 -0
- package/src/components/Dashboard/DashboardView.tsx +428 -0
- package/src/components/Dashboard/RowsDialog.tsx +4 -3
- package/src/components/Dashboard/TileCard.tsx +60 -11
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +13 -1
- package/src/components/Dashboard/telemetry.ts +17 -5
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +124 -138
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +111 -80
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +156 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +183 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +373 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +310 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +105 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +117 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +146 -108
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +179 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +330 -512
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +55 -25
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +142 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +310 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +39 -13
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +9 -26
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +102 -25
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +252 -780
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +23 -11
- package/src/components/DashboardBuilder/FilterStrip.tsx +130 -70
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +182 -0
- package/src/components/DashboardBuilder/InlineText.tsx +112 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +31 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +302 -163
- package/src/components/DashboardBuilder/TileMenu.tsx +125 -97
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +46 -0
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -44
- package/src/components/DashboardBuilder/catalog.ts +61 -57
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +258 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyTree.ts +159 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +174 -26
- package/src/components/DashboardBuilder/readDocument.ts +137 -45
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +52 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +89 -0
- package/src/components/DashboardBuilder/sortable.tsx +11 -10
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +768 -131
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +253 -0
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +760 -0
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +250 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +255 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +45 -9
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +57 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +30 -5
- package/src/components/DashboardBuilder/useTileResize.ts +31 -8
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +72 -29
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +186 -0
- package/src/components/Package/Package.create.spec.tsx +401 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +396 -177
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +14 -1
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +23 -8
- package/src/components/RenderedResult/ResultContainer.tsx +51 -13
- package/src/components/RenderedResult/ResultPanel.tsx +24 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +5 -11
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +3 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +23 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +112 -0
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +48 -0
- package/src/utils/malloyText.ts +368 -0
- package/src/utils/queryClient.ts +8 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -15
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -20
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/dist/components/DashboardBuilder/malloyText.d.ts +0 -64
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -122
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -168
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- package/src/components/DashboardBuilder/malloyText.ts +0 -214
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -6,7 +6,11 @@ import { openDocument } from "./testing/fixtures";
|
|
|
6
6
|
import * as fs from "fs";
|
|
7
7
|
import * as path from "path";
|
|
8
8
|
import { blockAbove, readDashboardDocument, readFailed } from "./readDocument";
|
|
9
|
+
import { readForEditor } from "./readForEditor";
|
|
9
10
|
import { parseMalloy, parseRefused } from "./malloyTree";
|
|
11
|
+
import { queryTile } from "./testing/fixtures";
|
|
12
|
+
import { tileKey } from "./document";
|
|
13
|
+
import { newNotebookSource } from "../DocumentCreate/newNotebook";
|
|
10
14
|
|
|
11
15
|
const REPO = path.resolve(import.meta.dir, "../../../../..");
|
|
12
16
|
|
|
@@ -361,10 +365,7 @@ source: b is two extend {
|
|
|
361
365
|
view: y is vy
|
|
362
366
|
}`);
|
|
363
367
|
expect(doc.sources.map((s) => s.name)).toEqual(["a", "b"]);
|
|
364
|
-
expect(doc.tiles.map(
|
|
365
|
-
"a.x",
|
|
366
|
-
"b.y",
|
|
367
|
-
]);
|
|
368
|
+
expect(doc.tiles.map(tileKey)).toEqual(["a.x", "b.y"]);
|
|
368
369
|
});
|
|
369
370
|
|
|
370
371
|
it("reads a filter binding written as a refinement", async () => {
|
|
@@ -374,11 +375,11 @@ import "../m.malloy"
|
|
|
374
375
|
source: a is one extend {
|
|
375
376
|
view: x is vx + { where: products.brand ~ $BRAND }
|
|
376
377
|
}`);
|
|
377
|
-
expect(doc
|
|
378
|
+
expect(queryTile(doc, 0).declaration).toEqual({
|
|
378
379
|
kind: "reference",
|
|
379
380
|
from: "vx",
|
|
380
381
|
});
|
|
381
|
-
expect(doc
|
|
382
|
+
expect(queryTile(doc, 0).filters).toEqual([
|
|
382
383
|
{ field: "products.brand", given: "BRAND" },
|
|
383
384
|
]);
|
|
384
385
|
});
|
|
@@ -409,6 +410,25 @@ source: a is one extend {
|
|
|
409
410
|
]);
|
|
410
411
|
});
|
|
411
412
|
|
|
413
|
+
it("reads the givens an extension's own where: reads, compound or not", async () => {
|
|
414
|
+
const doc =
|
|
415
|
+
await read(`## artifact { title="T" tiles=["a -> x", "b -> y"] }
|
|
416
|
+
import "../m.malloy"
|
|
417
|
+
|
|
418
|
+
source: a is one extend {
|
|
419
|
+
where: region ~ $REGION, (brand ~ $BRAND or brand = null)
|
|
420
|
+
view: x is vx + { where: cat ~ $CATEGORY }
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
source: b is two extend {
|
|
424
|
+
view: y is vy
|
|
425
|
+
}`);
|
|
426
|
+
expect(doc.sources.map((source) => source.scopedBy)).toEqual([
|
|
427
|
+
["REGION", "BRAND"],
|
|
428
|
+
undefined,
|
|
429
|
+
]);
|
|
430
|
+
});
|
|
431
|
+
|
|
412
432
|
// Givens are the one declaration the parser's symbol tree does not cover.
|
|
413
433
|
it("reads a dashboard-local given", async () => {
|
|
414
434
|
const doc = await read(`##! experimental.givens
|
|
@@ -445,7 +465,7 @@ import "../m.malloy"
|
|
|
445
465
|
source: a is one extend {
|
|
446
466
|
view: x is vx + { where: category ~ $CATEGORY, where: created_at >= $SINCE, limit: 5 }
|
|
447
467
|
}`);
|
|
448
|
-
expect(doc
|
|
468
|
+
expect(queryTile(doc, 0).filters).toEqual([
|
|
449
469
|
{ field: "category", given: "CATEGORY" },
|
|
450
470
|
{ field: "created_at", given: "SINCE", op: ">=" },
|
|
451
471
|
]);
|
|
@@ -467,8 +487,8 @@ source: a is one extend {
|
|
|
467
487
|
aggregate: n is count()
|
|
468
488
|
}
|
|
469
489
|
}`);
|
|
470
|
-
expect(doc
|
|
471
|
-
expect(doc
|
|
490
|
+
expect(queryTile(doc, 0).declaration).toEqual({ kind: "inline" });
|
|
491
|
+
expect(queryTile(doc, 0).filters).toEqual([
|
|
472
492
|
{ field: "category", given: "CATEGORY" },
|
|
473
493
|
]);
|
|
474
494
|
});
|
|
@@ -484,7 +504,7 @@ source: a is one extend {
|
|
|
484
504
|
where: category ~ $CATEGORY
|
|
485
505
|
}
|
|
486
506
|
}`);
|
|
487
|
-
expect(last
|
|
507
|
+
expect(queryTile(last, 0).filters).toEqual([
|
|
488
508
|
{ field: "category", given: "CATEGORY" },
|
|
489
509
|
]);
|
|
490
510
|
|
|
@@ -498,7 +518,7 @@ source: a is one extend {
|
|
|
498
518
|
aggregate: n is count()
|
|
499
519
|
}
|
|
500
520
|
}`);
|
|
501
|
-
expect(middle
|
|
521
|
+
expect(queryTile(middle, 0).filters).toEqual([
|
|
502
522
|
{ field: "category", given: "CATEGORY" },
|
|
503
523
|
]);
|
|
504
524
|
});
|
|
@@ -519,7 +539,7 @@ source: a is one extend {
|
|
|
519
539
|
}
|
|
520
540
|
}
|
|
521
541
|
}`);
|
|
522
|
-
expect(doc
|
|
542
|
+
expect(queryTile(doc, 0).filters).toBeUndefined();
|
|
523
543
|
});
|
|
524
544
|
|
|
525
545
|
// "Whose ENTIRE text is one or more binding clauses" — `a ~ $A and c = 1`
|
|
@@ -535,7 +555,7 @@ source: a is one extend {
|
|
|
535
555
|
aggregate: n is count()
|
|
536
556
|
}
|
|
537
557
|
}`);
|
|
538
|
-
expect(doc
|
|
558
|
+
expect(queryTile(doc, 0).filters).toBeUndefined();
|
|
539
559
|
});
|
|
540
560
|
|
|
541
561
|
// `cleanBindingClauses` accepts a following statement keyword as a clean
|
|
@@ -557,7 +577,7 @@ source: a is one extend {
|
|
|
557
577
|
where: a ~ $A, aggregate: n is count(), where: b ~ $B
|
|
558
578
|
}
|
|
559
579
|
}`);
|
|
560
|
-
expect(doc
|
|
580
|
+
expect(queryTile(doc, 0).filters).toEqual([
|
|
561
581
|
{ field: "a", given: "A" },
|
|
562
582
|
{ field: "b", given: "B" },
|
|
563
583
|
]);
|
|
@@ -575,7 +595,7 @@ source: a is one extend {
|
|
|
575
595
|
where: a ~ $A, where: b ~ $B
|
|
576
596
|
}
|
|
577
597
|
}`);
|
|
578
|
-
expect(doc
|
|
598
|
+
expect(queryTile(doc, 0).filters).toEqual([
|
|
579
599
|
{ field: "a", given: "A" },
|
|
580
600
|
{ field: "b", given: "B" },
|
|
581
601
|
]);
|
|
@@ -597,7 +617,7 @@ source: a is one extend {
|
|
|
597
617
|
select: category, n
|
|
598
618
|
}
|
|
599
619
|
}`);
|
|
600
|
-
expect(doc
|
|
620
|
+
expect(queryTile(doc, 0).filters).toEqual([
|
|
601
621
|
{ field: "category", given: "CATEGORY" },
|
|
602
622
|
]);
|
|
603
623
|
});
|
|
@@ -609,7 +629,7 @@ import "../m.malloy"
|
|
|
609
629
|
source: a is one extend {
|
|
610
630
|
view: x is { aggregate: n is count() where: category ~ $CATEGORY }
|
|
611
631
|
}`);
|
|
612
|
-
expect(doc
|
|
632
|
+
expect(queryTile(doc, 0).filters).toEqual([
|
|
613
633
|
{ field: "category", given: "CATEGORY" },
|
|
614
634
|
]);
|
|
615
635
|
});
|
|
@@ -624,7 +644,7 @@ import "../m.malloy"
|
|
|
624
644
|
source: a is one extend {
|
|
625
645
|
view: x is { where: category ~ $CATEGORY, aggregate: n is count() }
|
|
626
646
|
}`);
|
|
627
|
-
expect(doc
|
|
647
|
+
expect(queryTile(doc, 0).filters).toEqual([
|
|
628
648
|
{ field: "category", given: "CATEGORY" },
|
|
629
649
|
]);
|
|
630
650
|
});
|
|
@@ -640,7 +660,7 @@ source: a is one extend {
|
|
|
640
660
|
aggregate: n is count()
|
|
641
661
|
}
|
|
642
662
|
}`);
|
|
643
|
-
expect(opening
|
|
663
|
+
expect(queryTile(opening, 0).filters).toEqual([
|
|
644
664
|
{ field: "category", given: "CATEGORY" },
|
|
645
665
|
]);
|
|
646
666
|
|
|
@@ -652,7 +672,7 @@ source: a is one extend {
|
|
|
652
672
|
aggregate: n is count()
|
|
653
673
|
where: category ~ $CATEGORY }
|
|
654
674
|
}`);
|
|
655
|
-
expect(closing
|
|
675
|
+
expect(queryTile(closing, 0).filters).toEqual([
|
|
656
676
|
{ field: "category", given: "CATEGORY" },
|
|
657
677
|
]);
|
|
658
678
|
});
|
|
@@ -668,7 +688,7 @@ source: a is one extend {
|
|
|
668
688
|
|
|
669
689
|
view: x is { aggregate: n is count() }
|
|
670
690
|
}`);
|
|
671
|
-
expect(doc
|
|
691
|
+
expect(queryTile(doc, 0).filters).toBeUndefined();
|
|
672
692
|
});
|
|
673
693
|
});
|
|
674
694
|
|
|
@@ -732,6 +752,46 @@ source: a is one extend {
|
|
|
732
752
|
});
|
|
733
753
|
});
|
|
734
754
|
|
|
755
|
+
describe("readDashboardDocument: line endings", () => {
|
|
756
|
+
// A checkout with CRLF endings is the same document, so every field reads the same.
|
|
757
|
+
const SOURCES: Record<string, string> = {
|
|
758
|
+
"one-line tag, notes and tile tags": SIMPLE,
|
|
759
|
+
"a block tag and a text tile": newNotebookSource({
|
|
760
|
+
title: "Sales",
|
|
761
|
+
modelPath: "m.malloy",
|
|
762
|
+
source: "orders",
|
|
763
|
+
view: "by_brand",
|
|
764
|
+
}),
|
|
765
|
+
"a block description and a given contract": `##! experimental.givens
|
|
766
|
+
##|"
|
|
767
|
+
Block prose
|
|
768
|
+
|##
|
|
769
|
+
##| artifact { title="T"
|
|
770
|
+
tiles=["a -> x"]
|
|
771
|
+
}
|
|
772
|
+
|##
|
|
773
|
+
import { one } from "../m.malloy"
|
|
774
|
+
|
|
775
|
+
# label="Category" control=select
|
|
776
|
+
given: CATEGORY :: filter<string> is f''
|
|
777
|
+
|
|
778
|
+
source: a is one extend {
|
|
779
|
+
# colspan=6
|
|
780
|
+
view: x is vx + { where: category ~ $CATEGORY }
|
|
781
|
+
}`,
|
|
782
|
+
};
|
|
783
|
+
for (const [name, source] of Object.entries(SOURCES))
|
|
784
|
+
it(`reads ${name} the same with CRLF`, async () => {
|
|
785
|
+
const lf = await readDashboardDocument(source);
|
|
786
|
+
if (readFailed(lf)) throw new Error(lf.reason);
|
|
787
|
+
const crlf = await readDashboardDocument(
|
|
788
|
+
source.replace(/\n/g, "\r\n"),
|
|
789
|
+
);
|
|
790
|
+
if (readFailed(crlf)) throw new Error(crlf.reason);
|
|
791
|
+
expect(crlf.document).toEqual(lf.document);
|
|
792
|
+
});
|
|
793
|
+
});
|
|
794
|
+
|
|
735
795
|
describe("readDashboardDocument: what it refuses", () => {
|
|
736
796
|
// All-or-nothing, and every refusal names what it could not understand.
|
|
737
797
|
// "Cannot open this dashboard" with no reason reads as a bug.
|
|
@@ -772,11 +832,54 @@ describe("readDashboardDocument: what it refuses", () => {
|
|
|
772
832
|
const doc = await read(
|
|
773
833
|
`## artifact { title="T" tiles=["a -> x"] }\nimport "../m.malloy"\nsource: a is one extend {\n # colspan=6\n view: x is { aggregate: n }\n}`,
|
|
774
834
|
);
|
|
775
|
-
expect(doc
|
|
835
|
+
expect(queryTile(doc, 0).declaration).toEqual({ kind: "inline" });
|
|
776
836
|
expect(doc.tiles[0].colspan).toBe(6);
|
|
777
837
|
});
|
|
778
838
|
});
|
|
779
839
|
|
|
840
|
+
// The server serves such a file; the builder's tag rewrites only know `artifact { … }` leading.
|
|
841
|
+
describe("a tag whose artifact property is not the first", () => {
|
|
842
|
+
const rest = SIMPLE.split("\n").slice(5).join("\n");
|
|
843
|
+
const refused = async (text: string, modelPath?: string) => {
|
|
844
|
+
const result = await readDashboardDocument(text, modelPath);
|
|
845
|
+
if (!readFailed(result)) throw new Error("expected a refusal");
|
|
846
|
+
return result;
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
it("is refused with the reason, not read as untagged", async () => {
|
|
850
|
+
const result = await refused(
|
|
851
|
+
`## dashboard { columns=2 } artifact { title="Probe" tiles=["a -> by_cat"] }\n${rest}`,
|
|
852
|
+
);
|
|
853
|
+
expect(result.reason).toContain("`artifact { … }` first");
|
|
854
|
+
expect(result.reason).not.toContain("No `## artifact");
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
it("is refused in a ##| block too", async () => {
|
|
858
|
+
const result = await refused(
|
|
859
|
+
`##| dashboard { columns=2 }\n artifact { title="Probe" tiles=["a -> by_cat"] }\n|##\n${rest}`,
|
|
860
|
+
);
|
|
861
|
+
expect(result.reason).toContain("`artifact { … }` first");
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
it("is refused, not converted, for a cell-format notebook", async () => {
|
|
865
|
+
const open = await readForEditor(
|
|
866
|
+
`##! experimental.givens\n## dashboard { columns=2 } artifact { kind=notebook title="T" }\nrun: a -> by_cat`,
|
|
867
|
+
"notebooks/n.malloy",
|
|
868
|
+
);
|
|
869
|
+
expect(open.ok === false && open.reason).toContain(
|
|
870
|
+
"`artifact { … }` first",
|
|
871
|
+
);
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
it("still opens when artifact leads and another property follows", async () => {
|
|
875
|
+
const doc = await read(
|
|
876
|
+
`## artifact { title="Probe" tiles=["a -> by_cat"] } dashboard { columns=2 }\n${rest}`,
|
|
877
|
+
);
|
|
878
|
+
expect(doc.title).toBe("Probe");
|
|
879
|
+
expect(doc.columns).toBe(2);
|
|
880
|
+
});
|
|
881
|
+
});
|
|
882
|
+
|
|
780
883
|
/**
|
|
781
884
|
* The tripwire. All-or-nothing refusal is only reasonable while real dashboards
|
|
782
885
|
* open, so this asserts that every composite dashboard in the repository does.
|
|
@@ -835,11 +938,56 @@ describe("every composite dashboard in the repository opens", () => {
|
|
|
835
938
|
*/
|
|
836
939
|
describe("the compiler stays lazy", () => {
|
|
837
940
|
it("is never imported statically", () => {
|
|
838
|
-
const
|
|
839
|
-
path.join(import.meta.dir, "
|
|
941
|
+
const read = (file: string) =>
|
|
942
|
+
fs.readFileSync(path.join(import.meta.dir, file), "utf8");
|
|
943
|
+
const staticImport = /^\s*import\s[^(]*@malloydata\/malloy"/m;
|
|
944
|
+
expect(read("malloyTree.ts")).not.toMatch(staticImport);
|
|
945
|
+
expect(read("legacyNotebook.ts")).not.toMatch(staticImport);
|
|
946
|
+
expect(read("malloyTree.ts")).toContain("await loadMalloy()");
|
|
947
|
+
expect(read("loadMalloy.ts")).toContain(
|
|
948
|
+
'await import("@malloydata/malloy")',
|
|
949
|
+
);
|
|
950
|
+
for (const pkg of ["malloy-tag", "malloy-query-builder"])
|
|
951
|
+
expect(read("loadMalloy.ts")).toContain(
|
|
952
|
+
`await import("@malloydata/${pkg}")`,
|
|
953
|
+
);
|
|
954
|
+
for (const file of ["readDocument.ts", "legacyNotebook.ts"])
|
|
955
|
+
expect(read(file)).not.toContain('import("@malloydata/malloy-tag")');
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
describe("the kind of a document held as text", () => {
|
|
960
|
+
const { cases } = JSON.parse(
|
|
961
|
+
fs.readFileSync(
|
|
962
|
+
path.join(import.meta.dir, "testing/documentKindRule.json"),
|
|
840
963
|
"utf8",
|
|
964
|
+
),
|
|
965
|
+
) as { cases: { name: string; source: string; kind: string }[] };
|
|
966
|
+
|
|
967
|
+
// One case table for this reader and the server's `submittedTextKind`, whose spec reads the same file.
|
|
968
|
+
for (const { name, source, kind } of cases) {
|
|
969
|
+
it(`${name}: ${kind}`, async () => {
|
|
970
|
+
const result = await readDashboardDocument(source, undefined, true);
|
|
971
|
+
const notebook = readFailed(result)
|
|
972
|
+
? result.legacyNotebook === true
|
|
973
|
+
: result.document.kind === "notebook";
|
|
974
|
+
expect(notebook).toBe(kind === "notebook");
|
|
975
|
+
});
|
|
976
|
+
}
|
|
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",
|
|
841
988
|
);
|
|
842
|
-
expect(
|
|
843
|
-
|
|
989
|
+
expect(
|
|
990
|
+
readFailed(inDashboards) && inDashboards.legacyNotebook,
|
|
991
|
+
).toBeFalsy();
|
|
844
992
|
});
|
|
845
993
|
});
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import {
|
|
5
|
+
chartLinesOf,
|
|
6
|
+
chartStateOfTagLines,
|
|
7
|
+
type ChartState,
|
|
8
|
+
} from "./chartLine";
|
|
4
9
|
import type {
|
|
5
10
|
DashboardDocument,
|
|
6
11
|
DashboardDrill,
|
|
@@ -9,20 +14,27 @@ import type {
|
|
|
9
14
|
DashboardTile,
|
|
10
15
|
LocalGiven,
|
|
11
16
|
} from "./document";
|
|
17
|
+
import { isTextTile } from "./document";
|
|
18
|
+
import { loadMalloyTag } from "./loadMalloy";
|
|
19
|
+
import { parseTagLines } from "./tagParse";
|
|
12
20
|
import {
|
|
13
21
|
parseMalloy,
|
|
14
22
|
parseRefused,
|
|
23
|
+
readTileList,
|
|
15
24
|
type ParsedMalloy,
|
|
16
25
|
type TreeStage,
|
|
17
26
|
type TreeView,
|
|
18
27
|
} from "./malloyTree";
|
|
19
28
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
ARTIFACT_NOT_FIRST,
|
|
30
|
+
artifactLeads,
|
|
31
|
+
artifactTag as locateArtifactTag,
|
|
22
32
|
descriptionNotes,
|
|
23
|
-
|
|
33
|
+
readPath,
|
|
34
|
+
splitSourceLines,
|
|
35
|
+
tagAnnotation,
|
|
24
36
|
tileSteps,
|
|
25
|
-
} from "
|
|
37
|
+
} from "../../utils/malloyText";
|
|
26
38
|
|
|
27
39
|
/**
|
|
28
40
|
* Read a `dashboards/*.malloy` file into a {@link DashboardDocument}.
|
|
@@ -54,6 +66,8 @@ export interface ReadFailure {
|
|
|
54
66
|
reason: string;
|
|
55
67
|
/** 1-based, for a message that can point at the line. */
|
|
56
68
|
line?: number;
|
|
69
|
+
/** The file is a `kind=notebook` in the run-cell format, which `convertLegacyNotebook` turns into a layout notebook. */
|
|
70
|
+
legacyNotebook?: true;
|
|
57
71
|
}
|
|
58
72
|
|
|
59
73
|
export type ReadResult =
|
|
@@ -129,26 +143,17 @@ export function blockAbove(
|
|
|
129
143
|
/** Just the text of a block's tags, which is what `parseAnnotation` takes. */
|
|
130
144
|
const tagText = (tags: Array<{ text: string }>) => tags.map((t) => t.text);
|
|
131
145
|
|
|
132
|
-
/** The
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
|
|
146
|
+
/** The tile's `chart` property, absent when its wrapper carries no chart line; a custom one also carries the lines. */
|
|
147
|
+
function chartField(tags: Array<{ text: string }>): {
|
|
148
|
+
chart?: ChartState;
|
|
149
|
+
chartLines?: string[];
|
|
136
150
|
} {
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
text.startsWith("##") &&
|
|
145
|
-
!text.startsWith('##"') &&
|
|
146
|
-
!text.startsWith("##!") &&
|
|
147
|
-
!(note?.level === 2 && !note.block)
|
|
148
|
-
)
|
|
149
|
-
artifact.push(text);
|
|
150
|
-
}
|
|
151
|
-
return { description: descriptionNotes(lines).text, artifact };
|
|
151
|
+
const lines = tagText(tags);
|
|
152
|
+
const chart = chartStateOfTagLines(lines);
|
|
153
|
+
if (chart === undefined) return {};
|
|
154
|
+
return chart === "custom"
|
|
155
|
+
? { chart, chartLines: chartLinesOf(lines) }
|
|
156
|
+
: { chart };
|
|
152
157
|
}
|
|
153
158
|
|
|
154
159
|
/**
|
|
@@ -169,7 +174,11 @@ function filtersOf(
|
|
|
169
174
|
for (const clause of where.clauses) {
|
|
170
175
|
if (!clause.binding) continue;
|
|
171
176
|
const { field, op, given } = clause.binding;
|
|
172
|
-
out.push({
|
|
177
|
+
out.push({
|
|
178
|
+
field: readPath(field),
|
|
179
|
+
given,
|
|
180
|
+
...(op === "~" ? {} : { op }),
|
|
181
|
+
});
|
|
173
182
|
}
|
|
174
183
|
return out.length > 0 ? out : undefined;
|
|
175
184
|
}
|
|
@@ -266,22 +275,33 @@ function gridWidth(
|
|
|
266
275
|
return Number.isInteger(value) && value >= 1 ? value : undefined;
|
|
267
276
|
}
|
|
268
277
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const key = artifactLine.search(/tiles\s*=\s*\[/);
|
|
272
|
-
if (key < 0) return [];
|
|
273
|
-
const open = artifactLine.indexOf("[", key);
|
|
274
|
-
const close = artifactLine.indexOf("]", open);
|
|
275
|
-
if (close < 0) return [];
|
|
276
|
-
const list = artifactLine.slice(open + 1, close);
|
|
277
|
-
return [...list.matchAll(/"([^"]+)"/g)].map((m) => m[1]);
|
|
278
|
-
}
|
|
278
|
+
const QUOTED_ENTRY = /^"((?:[^"\\]|\\.)+)"$/;
|
|
279
|
+
const TEXT_ENTRY = /^([A-Za-z_][A-Za-z0-9_]*)\s*\{/;
|
|
279
280
|
|
|
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. */
|
|
280
282
|
export async function readDashboardDocument(
|
|
281
283
|
sourceText: string,
|
|
284
|
+
modelPath?: string,
|
|
285
|
+
/** A document the host keeps as text has no folder to take a kind from, so the layout decides. */
|
|
286
|
+
textHeld = false,
|
|
287
|
+
): Promise<ReadResult> {
|
|
288
|
+
try {
|
|
289
|
+
return await readDocumentText(sourceText, modelPath, textHeld);
|
|
290
|
+
} catch (error) {
|
|
291
|
+
return {
|
|
292
|
+
ok: false,
|
|
293
|
+
reason: `A value in this file's tags cannot be read (${error instanceof Error ? error.message : String(error)}), so it cannot be opened in the builder.`,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async function readDocumentText(
|
|
299
|
+
sourceText: string,
|
|
300
|
+
modelPath: string | undefined,
|
|
301
|
+
textHeld: boolean,
|
|
282
302
|
): Promise<ReadResult> {
|
|
283
|
-
const { parseAnnotation } = await
|
|
284
|
-
const lines = sourceText
|
|
303
|
+
const { parseAnnotation } = await loadMalloyTag();
|
|
304
|
+
const lines = splitSourceLines(sourceText);
|
|
285
305
|
|
|
286
306
|
const parse = await parseMalloy(sourceText);
|
|
287
307
|
if (parseRefused(parse))
|
|
@@ -292,24 +312,55 @@ export async function readDashboardDocument(
|
|
|
292
312
|
};
|
|
293
313
|
const parsed = parse.parsed;
|
|
294
314
|
|
|
295
|
-
const
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
315
|
+
const description = descriptionNotes(lines).text;
|
|
316
|
+
const artifactAt = locateArtifactTag(lines);
|
|
317
|
+
if (artifactAt === undefined) {
|
|
298
318
|
return {
|
|
299
319
|
ok: false,
|
|
300
320
|
reason:
|
|
301
321
|
"No `## artifact { … }` tag, so this file is not a composite dashboard.",
|
|
302
322
|
};
|
|
303
323
|
}
|
|
324
|
+
if (!artifactLeads(artifactAt.text))
|
|
325
|
+
return {
|
|
326
|
+
ok: false,
|
|
327
|
+
reason: ARTIFACT_NOT_FIRST,
|
|
328
|
+
line: artifactAt.from + 1,
|
|
329
|
+
};
|
|
304
330
|
|
|
305
|
-
const tag = parseAnnotation
|
|
331
|
+
const { tag, errors: tagErrors } = parseTagLines(parseAnnotation, [
|
|
332
|
+
tagAnnotation(artifactAt.text),
|
|
333
|
+
]);
|
|
306
334
|
const artifactTag = tag?.tag("artifact");
|
|
307
|
-
const
|
|
308
|
-
|
|
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
|
+
const list = readTileList(artifactAt.text);
|
|
346
|
+
if (list === undefined) {
|
|
347
|
+
if (tagErrors.length > 0)
|
|
348
|
+
return {
|
|
349
|
+
ok: false,
|
|
350
|
+
reason: `The \`## artifact\` tag does not parse: ${tagErrors[0]}`,
|
|
351
|
+
};
|
|
352
|
+
// A notebook is told from a layout one by whether it lists tiles at all.
|
|
353
|
+
if (kind === "notebook")
|
|
354
|
+
return {
|
|
355
|
+
ok: false,
|
|
356
|
+
legacyNotebook: true,
|
|
357
|
+
reason:
|
|
358
|
+
"This notebook is in the cell format, with no `tiles=[…]` list.",
|
|
359
|
+
};
|
|
309
360
|
return {
|
|
310
361
|
ok: false,
|
|
311
362
|
reason:
|
|
312
|
-
"The `## artifact` tag
|
|
363
|
+
"The `## artifact` tag has no `tiles=[…]` list the builder can read.",
|
|
313
364
|
};
|
|
314
365
|
}
|
|
315
366
|
|
|
@@ -329,6 +380,12 @@ export async function readDashboardDocument(
|
|
|
329
380
|
name: d.name,
|
|
330
381
|
expression: d.expression,
|
|
331
382
|
}));
|
|
383
|
+
const scopedBy = new Set(
|
|
384
|
+
source.wheres.flatMap((where) =>
|
|
385
|
+
where.clauses.flatMap((clause) => clause.givens),
|
|
386
|
+
),
|
|
387
|
+
);
|
|
388
|
+
if (scopedBy.size > 0) entry.scopedBy = Array.from(scopedBy);
|
|
332
389
|
sources.push(entry);
|
|
333
390
|
|
|
334
391
|
// A `# drill` is a tag on a dimension's declaration, so the dimensions
|
|
@@ -357,8 +414,40 @@ export async function readDashboardDocument(
|
|
|
357
414
|
}
|
|
358
415
|
|
|
359
416
|
const tiles: DashboardTile[] = [];
|
|
360
|
-
for (const
|
|
361
|
-
const
|
|
417
|
+
for (const { text: entryText } of list.entries) {
|
|
418
|
+
const quoted = QUOTED_ENTRY.exec(entryText);
|
|
419
|
+
const textName = quoted ? undefined : TEXT_ENTRY.exec(entryText)?.[1];
|
|
420
|
+
if (textName !== undefined) {
|
|
421
|
+
const textTag = parseAnnotation([`# ${entryText}`]).tag?.tag(textName);
|
|
422
|
+
if (textTag?.text("kind") !== "text") {
|
|
423
|
+
return {
|
|
424
|
+
ok: false,
|
|
425
|
+
reason:
|
|
426
|
+
`The tile \`${entryText}\` is neither a quoted \`source -> view\` ` +
|
|
427
|
+
`expression nor a \`${textName} { kind=text }\` entry, which are ` +
|
|
428
|
+
`the only forms the builder can lay out.`,
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
if (tiles.some((tile) => isTextTile(tile) && tile.name === textName)) {
|
|
432
|
+
return {
|
|
433
|
+
ok: false,
|
|
434
|
+
reason: `Two text tiles are named \`${textName}\`, so the builder cannot tell them apart.`,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
const colspan = gridWidth(textTag, "colspan");
|
|
438
|
+
tiles.push({
|
|
439
|
+
kind: "text",
|
|
440
|
+
name: textName,
|
|
441
|
+
markdown:
|
|
442
|
+
parsed.textBlocks.find((block) => block.name === textName)
|
|
443
|
+
?.body ?? "",
|
|
444
|
+
...(colspan === undefined ? {} : { colspan }),
|
|
445
|
+
...(textTag.has("break") ? { break: true } : {}),
|
|
446
|
+
});
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
const entry = quoted?.[1] ?? entryText;
|
|
450
|
+
const steps = quoted ? tileSteps(entry) : undefined;
|
|
362
451
|
if (!steps) {
|
|
363
452
|
return {
|
|
364
453
|
ok: false,
|
|
@@ -415,6 +504,7 @@ export async function readDashboardDocument(
|
|
|
415
504
|
...(t?.numeric("colspan") !== undefined
|
|
416
505
|
? { colspan: t.numeric("colspan") as number }
|
|
417
506
|
: {}),
|
|
507
|
+
...chartField(view.tags),
|
|
418
508
|
...(t?.has("break") ? { break: true } : {}),
|
|
419
509
|
...(t?.has("borderless") ? { borderless: true } : {}),
|
|
420
510
|
});
|
|
@@ -441,6 +531,7 @@ export async function readDashboardDocument(
|
|
|
441
531
|
...(t?.numeric("colspan") !== undefined
|
|
442
532
|
? { colspan: t.numeric("colspan") as number }
|
|
443
533
|
: {}),
|
|
534
|
+
...chartField(view.tags),
|
|
444
535
|
...(t?.has("break") ? { break: true } : {}),
|
|
445
536
|
...(t?.has("borderless") ? { borderless: true } : {}),
|
|
446
537
|
});
|
|
@@ -467,6 +558,7 @@ export async function readDashboardDocument(
|
|
|
467
558
|
return {
|
|
468
559
|
ok: true,
|
|
469
560
|
document: {
|
|
561
|
+
...(kind ? { kind } : {}),
|
|
470
562
|
title: artifactTag?.text("title") ?? "",
|
|
471
563
|
...(description ? { description } : {}),
|
|
472
564
|
...(columnsTag === undefined ? {} : { columns: columnsTag }),
|