@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import {
|
|
6
|
+
loadMalloy,
|
|
7
|
+
loadMalloyTag,
|
|
8
|
+
loadQueryBuilder,
|
|
9
|
+
unwrapMalloy,
|
|
10
|
+
unwrapMalloyTag,
|
|
11
|
+
unwrapQueryBuilder,
|
|
12
|
+
} from "./loadMalloy";
|
|
13
|
+
|
|
14
|
+
type Namespace = Parameters<typeof unwrapMalloy>[0];
|
|
15
|
+
|
|
16
|
+
describe("unwrapMalloy", () => {
|
|
17
|
+
class MalloyTranslator {}
|
|
18
|
+
|
|
19
|
+
it("returns an ESM-style namespace as it is", () => {
|
|
20
|
+
const ns = { MalloyTranslator, default: { other: 1 } };
|
|
21
|
+
expect(unwrapMalloy(ns as unknown as Namespace)).toBe(
|
|
22
|
+
ns as unknown as Namespace,
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("unwraps a default-only namespace from a bundled CommonJS import", () => {
|
|
27
|
+
const cjs = { MalloyTranslator };
|
|
28
|
+
const unwrapped = unwrapMalloy({ default: cjs } as unknown as Namespace);
|
|
29
|
+
expect(unwrapped.MalloyTranslator as unknown).toBe(MalloyTranslator);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("loads the real package with a constructible translator", async () => {
|
|
33
|
+
const malloy = await loadMalloy();
|
|
34
|
+
expect(typeof malloy.MalloyTranslator).toBe("function");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("unwrapMalloyTag", () => {
|
|
39
|
+
type Tag = Parameters<typeof unwrapMalloyTag>[0];
|
|
40
|
+
const parseAnnotation = () => {};
|
|
41
|
+
|
|
42
|
+
it("returns an ESM-style namespace as it is", () => {
|
|
43
|
+
const ns = { parseAnnotation, default: { other: 1 } } as unknown as Tag;
|
|
44
|
+
expect(unwrapMalloyTag(ns)).toBe(ns);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("unwraps a default-only namespace from a bundled CommonJS import", () => {
|
|
48
|
+
const unwrapped = unwrapMalloyTag({
|
|
49
|
+
default: { parseAnnotation },
|
|
50
|
+
} as unknown as Tag);
|
|
51
|
+
expect(unwrapped.parseAnnotation as unknown).toBe(parseAnnotation);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("loads the real package with a callable parser", async () => {
|
|
55
|
+
const tag = await loadMalloyTag();
|
|
56
|
+
expect(typeof tag.parseAnnotation).toBe("function");
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe("unwrapQueryBuilder", () => {
|
|
61
|
+
type Builder = Parameters<typeof unwrapQueryBuilder>[0];
|
|
62
|
+
class ASTQuery {}
|
|
63
|
+
|
|
64
|
+
it("returns an ESM-style namespace as it is", () => {
|
|
65
|
+
const ns = { ASTQuery, default: { other: 1 } } as unknown as Builder;
|
|
66
|
+
expect(unwrapQueryBuilder(ns)).toBe(ns);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("unwraps a default-only namespace from a bundled CommonJS import", () => {
|
|
70
|
+
const unwrapped = unwrapQueryBuilder({
|
|
71
|
+
default: { ASTQuery },
|
|
72
|
+
} as unknown as Builder);
|
|
73
|
+
expect(unwrapped.ASTQuery as unknown).toBe(ASTQuery);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("loads the real package with a constructible query", async () => {
|
|
77
|
+
const builder = await loadQueryBuilder();
|
|
78
|
+
expect(typeof builder.ASTQuery).toBe("function");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
type Malloy = typeof import("@malloydata/malloy");
|
|
5
|
+
type MalloyTag = typeof import("@malloydata/malloy-tag");
|
|
6
|
+
type QueryBuilder = typeof import("@malloydata/malloy-query-builder");
|
|
7
|
+
|
|
8
|
+
// A bundler's CommonJS interop (Vite's dep optimizer) can hand back a namespace holding only `default`.
|
|
9
|
+
function unwrapNamespace<T extends object>(ns: T, probe: keyof T): T {
|
|
10
|
+
if (ns[probe]) return ns;
|
|
11
|
+
const inner = (ns as unknown as { default?: T }).default;
|
|
12
|
+
return inner?.[probe] ? inner : ns;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const unwrapMalloy = (ns: Malloy): Malloy =>
|
|
16
|
+
unwrapNamespace(ns, "MalloyTranslator");
|
|
17
|
+
|
|
18
|
+
export const unwrapMalloyTag = (ns: MalloyTag): MalloyTag =>
|
|
19
|
+
unwrapNamespace(ns, "parseAnnotation");
|
|
20
|
+
|
|
21
|
+
export const unwrapQueryBuilder = (ns: QueryBuilder): QueryBuilder =>
|
|
22
|
+
unwrapNamespace(ns, "ASTQuery");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Imported dynamically, never statically: `builder-entry.ts` installs the
|
|
26
|
+
* `process.env` shim the parser's dependencies read at module scope, and a
|
|
27
|
+
* static import would be evaluated before that shim runs.
|
|
28
|
+
*/
|
|
29
|
+
export async function loadMalloy(): Promise<Malloy> {
|
|
30
|
+
return unwrapMalloy(await import("@malloydata/malloy"));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function loadMalloyTag(): Promise<MalloyTag> {
|
|
34
|
+
return unwrapMalloyTag(await import("@malloydata/malloy-tag"));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function loadQueryBuilder(): Promise<QueryBuilder> {
|
|
38
|
+
return unwrapQueryBuilder(await import("@malloydata/malloy-query-builder"));
|
|
39
|
+
}
|
|
@@ -20,7 +20,12 @@
|
|
|
20
20
|
* minifiers leave alone.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
blockSpans,
|
|
25
|
+
markdownLines,
|
|
26
|
+
textBlockOpener,
|
|
27
|
+
} from "../../utils/malloyText";
|
|
28
|
+
import { loadMalloy } from "./loadMalloy";
|
|
24
29
|
|
|
25
30
|
/** A half-open range of UTF-16 offsets into the source text. */
|
|
26
31
|
export interface Span {
|
|
@@ -151,6 +156,17 @@ export interface TreeImport extends Positioned {
|
|
|
151
156
|
statement: Span;
|
|
152
157
|
}
|
|
153
158
|
|
|
159
|
+
/** A floating `##|(markdown) [name]` … `|##` block, which a dashboard reads as a text tile's body. */
|
|
160
|
+
export interface TreeTextBlock extends Positioned {
|
|
161
|
+
/** Absent when the opener has no name, or more than one word after the route. */
|
|
162
|
+
name?: string;
|
|
163
|
+
route: "markdown" | "text";
|
|
164
|
+
/** Text on the opener line (unless it is only the name), then the body lines; no trailing newline. */
|
|
165
|
+
body: string;
|
|
166
|
+
/** From the opener's line start through the closer's newline: the whole-line extent a writer replaces or removes. */
|
|
167
|
+
span: Span;
|
|
168
|
+
}
|
|
169
|
+
|
|
154
170
|
export interface ParsedMalloy {
|
|
155
171
|
text: string;
|
|
156
172
|
/** 0-based line -> offset of its first character. */
|
|
@@ -158,6 +174,8 @@ export interface ParsedMalloy {
|
|
|
158
174
|
imports: TreeImport[];
|
|
159
175
|
sources: TreeSource[];
|
|
160
176
|
givens: TreeGiven[];
|
|
177
|
+
/** The closed floating `(markdown)` / `(text)` blocks, in file order. */
|
|
178
|
+
textBlocks: TreeTextBlock[];
|
|
161
179
|
/** The comment token on `line`, if the line ends with one. */
|
|
162
180
|
trailingComment(line: number): Span | undefined;
|
|
163
181
|
/**
|
|
@@ -198,14 +216,14 @@ export const parseRefused = (r: ParseResult): r is ParseRefusal =>
|
|
|
198
216
|
/* Node identity */
|
|
199
217
|
/* ------------------------------------------------------------------ */
|
|
200
218
|
|
|
201
|
-
interface TokenStream {
|
|
219
|
+
export interface TokenStream {
|
|
202
220
|
tokenSource?: {
|
|
203
221
|
vocabulary?: { getSymbolicName(type: number): string | undefined };
|
|
204
222
|
};
|
|
205
223
|
getTokens?(): Array<{ type: number; startIndex: number; stopIndex: number }>;
|
|
206
224
|
}
|
|
207
225
|
|
|
208
|
-
type Ctx = Record<string, unknown> & {
|
|
226
|
+
export type Ctx = Record<string, unknown> & {
|
|
209
227
|
ruleIndex?: number;
|
|
210
228
|
childCount?: number;
|
|
211
229
|
getChild(i: number): Ctx;
|
|
@@ -219,7 +237,7 @@ const has = (c: unknown, ...accessors: string[]): boolean =>
|
|
|
219
237
|
);
|
|
220
238
|
|
|
221
239
|
/** A rule context we can take a range from; terminals and empties are not. */
|
|
222
|
-
const isRule = (c: Ctx | undefined): boolean =>
|
|
240
|
+
export const isRule = (c: Ctx | undefined): boolean =>
|
|
223
241
|
c !== undefined && c.ruleIndex !== undefined && (c.childCount ?? 0) > 0;
|
|
224
242
|
|
|
225
243
|
const IS = {
|
|
@@ -283,7 +301,7 @@ function lineStartsOf(text: string): number[] {
|
|
|
283
301
|
|
|
284
302
|
/* ------------------------------------------------------------------ */
|
|
285
303
|
|
|
286
|
-
class Reader {
|
|
304
|
+
export class Reader {
|
|
287
305
|
private readonly map: Int32Array;
|
|
288
306
|
readonly lineStarts: number[];
|
|
289
307
|
/**
|
|
@@ -531,6 +549,8 @@ function readViewBody(r: Reader, vExpr: Ctx): TreeViewBody {
|
|
|
531
549
|
return { kind: "unsupported", why: "a chained refinement" };
|
|
532
550
|
base = inner[0];
|
|
533
551
|
}
|
|
552
|
+
if (base && IS.segParen(base))
|
|
553
|
+
return { kind: "unsupported", why: "a parenthesized expression" };
|
|
534
554
|
if (!base || !IS.segField(base))
|
|
535
555
|
return {
|
|
536
556
|
kind: "unsupported",
|
|
@@ -812,6 +832,7 @@ export async function parseMalloy(text: string): Promise<ParseResult> {
|
|
|
812
832
|
imports: readImports(r, root),
|
|
813
833
|
sources,
|
|
814
834
|
givens: readGivens(r, root),
|
|
835
|
+
textBlocks: readTextBlocks(r, tokenStream),
|
|
815
836
|
trailingComment: (line) => comments.trailing.get(line),
|
|
816
837
|
comments: comments.all,
|
|
817
838
|
commentLine: (line) => comments.lines.has(line),
|
|
@@ -829,6 +850,8 @@ export async function parseMalloy(text: string): Promise<ParseResult> {
|
|
|
829
850
|
export interface MalloyProblem {
|
|
830
851
|
code?: string;
|
|
831
852
|
message?: string;
|
|
853
|
+
/** 0-based. */
|
|
854
|
+
at?: { range?: { start?: { line?: number } } };
|
|
832
855
|
}
|
|
833
856
|
|
|
834
857
|
/** One parse of one file, stopped at the parse step. */
|
|
@@ -854,7 +877,7 @@ export async function translate(
|
|
|
854
877
|
// Imported dynamically, never statically: `builder-entry.ts` installs the
|
|
855
878
|
// `process.env` shim the parser's dependencies read at module scope, and a
|
|
856
879
|
// static import would be evaluated before that shim runs.
|
|
857
|
-
const { MalloyTranslator } = await
|
|
880
|
+
const { MalloyTranslator } = await loadMalloy();
|
|
858
881
|
const translator = new MalloyTranslator(url, null, {
|
|
859
882
|
urls: { [url]: text },
|
|
860
883
|
}) as unknown as {
|
|
@@ -882,7 +905,7 @@ export async function translate(
|
|
|
882
905
|
* that follows code is a trailing comment, and anything appended to that line
|
|
883
906
|
* has to go before it.
|
|
884
907
|
*/
|
|
885
|
-
function commentIndex(
|
|
908
|
+
export function commentIndex(
|
|
886
909
|
r: Reader,
|
|
887
910
|
tokenStream: TokenStream,
|
|
888
911
|
): { trailing: Map<number, Span>; lines: Set<number>; all: Span[] } {
|
|
@@ -976,3 +999,132 @@ function blockStart(
|
|
|
976
999
|
}
|
|
977
1000
|
return start;
|
|
978
1001
|
}
|
|
1002
|
+
|
|
1003
|
+
/* ------------------------------------------------------------------ */
|
|
1004
|
+
/* Text tiles */
|
|
1005
|
+
/* ------------------------------------------------------------------ */
|
|
1006
|
+
|
|
1007
|
+
/** The closed `##|(markdown)` / `##|(text)` blocks, read from the lexer's own tokens so a `|##` in a string or comment never closes one. */
|
|
1008
|
+
function readTextBlocks(r: Reader, stream: TokenStream): TreeTextBlock[] {
|
|
1009
|
+
const tokens = stream.getTokens?.() ?? [];
|
|
1010
|
+
const vocabulary = stream.tokenSource?.vocabulary;
|
|
1011
|
+
const symbolOf = (token: { type: number }) =>
|
|
1012
|
+
vocabulary?.getSymbolicName(token.type);
|
|
1013
|
+
const tokenText = (token: { startIndex: number; stopIndex: number }) =>
|
|
1014
|
+
r.text.slice(
|
|
1015
|
+
r.utf16(token.startIndex) ?? 0,
|
|
1016
|
+
r.utf16(token.stopIndex + 1) ?? r.text.length,
|
|
1017
|
+
);
|
|
1018
|
+
const blocks: TreeTextBlock[] = [];
|
|
1019
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
1020
|
+
if (symbolOf(tokens[i]) !== "DOC_BLOCK_ANNOTATION_BEGIN") continue;
|
|
1021
|
+
const opener = textBlockOpener(
|
|
1022
|
+
tokenText(tokens[i]).replace(/\r?\n$/, ""),
|
|
1023
|
+
);
|
|
1024
|
+
if (!opener) continue;
|
|
1025
|
+
const lines: string[] = [];
|
|
1026
|
+
let j = i + 1;
|
|
1027
|
+
for (; symbolOf(tokens[j] ?? tokens[i]) === "BLOCK_ANNOTATION_TEXT"; j++)
|
|
1028
|
+
lines.push(tokenText(tokens[j]));
|
|
1029
|
+
const closer = tokens[j];
|
|
1030
|
+
if (!closer || symbolOf(closer) !== "BLOCK_ANNOTATION_END") continue;
|
|
1031
|
+
const first = r.line(r.utf16(tokens[i].startIndex) ?? 0);
|
|
1032
|
+
const end = r.utf16(closer.stopIndex + 1) ?? r.text.length;
|
|
1033
|
+
const onOpener =
|
|
1034
|
+
opener.name === undefined && opener.rest ? [`${opener.rest}\n`] : [];
|
|
1035
|
+
blocks.push({
|
|
1036
|
+
...(opener.name === undefined ? {} : { name: opener.name }),
|
|
1037
|
+
route: opener.route,
|
|
1038
|
+
body: [...onOpener, ...lines]
|
|
1039
|
+
.join("")
|
|
1040
|
+
.replace(/\r\n?/g, "\n")
|
|
1041
|
+
.replace(/\n$/, ""),
|
|
1042
|
+
span: { start: r.lineStarts[first], end },
|
|
1043
|
+
line: first,
|
|
1044
|
+
});
|
|
1045
|
+
i = j;
|
|
1046
|
+
}
|
|
1047
|
+
return blocks;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
/** One `tiles=[…]` entry, exactly as written, with where it sits in the line. */
|
|
1051
|
+
export interface TileEntry {
|
|
1052
|
+
text: string;
|
|
1053
|
+
span: Span;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
export interface TileList {
|
|
1057
|
+
/** Offsets of `[` and the matching `]` in the line. */
|
|
1058
|
+
open: number;
|
|
1059
|
+
close: number;
|
|
1060
|
+
entries: TileEntry[];
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/** The index of the quote closing the string that opens at `open`. */
|
|
1064
|
+
function stringEnd(line: string, open: number): number {
|
|
1065
|
+
for (let i = open + 1; i < line.length; i++) {
|
|
1066
|
+
if (line[i] === "\\") i++;
|
|
1067
|
+
else if (line[i] === '"') return i;
|
|
1068
|
+
}
|
|
1069
|
+
return line.length;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* The `tiles=[…]` list of a one-line `## artifact { … }` tag, as written: quoted run expressions
|
|
1074
|
+
* and `name { kind=text … }` entries alike. Undefined when the tag has no list or it never closes.
|
|
1075
|
+
* Strings and nested braces are skipped, so a title containing `tiles=[` or a `]` is not the list.
|
|
1076
|
+
*/
|
|
1077
|
+
export function readTileList(line: string): TileList | undefined {
|
|
1078
|
+
let depth = 0;
|
|
1079
|
+
let groups = 0;
|
|
1080
|
+
for (let i = 0; i < line.length; i++) {
|
|
1081
|
+
const c = line[i];
|
|
1082
|
+
if (c === '"') i = stringEnd(line, i);
|
|
1083
|
+
else if (c === "{" || c === "[") {
|
|
1084
|
+
if (depth++ === 0) groups++;
|
|
1085
|
+
} else if (c === "}" || c === "]") depth--;
|
|
1086
|
+
else if (
|
|
1087
|
+
groups === 1 &&
|
|
1088
|
+
depth === 1 &&
|
|
1089
|
+
line.startsWith("tiles", i) &&
|
|
1090
|
+
!/[A-Za-z0-9_]/.test(line[i - 1] ?? " ")
|
|
1091
|
+
) {
|
|
1092
|
+
const key = /^tiles\s*=\s*\[/.exec(line.slice(i));
|
|
1093
|
+
if (key) return scanTileList(line, i + key[0].length - 1);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
return undefined;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
function scanTileList(line: string, open: number): TileList | undefined {
|
|
1100
|
+
const entries: TileEntry[] = [];
|
|
1101
|
+
let depth = 0;
|
|
1102
|
+
let from = open + 1;
|
|
1103
|
+
const push = (to: number) => {
|
|
1104
|
+
const text = line.slice(from, to);
|
|
1105
|
+
const lead = text.length - text.trimStart().length;
|
|
1106
|
+
const trimmed = text.trim();
|
|
1107
|
+
if (trimmed !== "")
|
|
1108
|
+
entries.push({
|
|
1109
|
+
text: trimmed,
|
|
1110
|
+
span: { start: from + lead, end: from + lead + trimmed.length },
|
|
1111
|
+
});
|
|
1112
|
+
};
|
|
1113
|
+
for (let i = open + 1; i < line.length; i++) {
|
|
1114
|
+
const c = line[i];
|
|
1115
|
+
if (c === '"') i = stringEnd(line, i);
|
|
1116
|
+
else if (c === "{" || c === "[") depth++;
|
|
1117
|
+
else if (c === "}") depth--;
|
|
1118
|
+
else if (c === "]") {
|
|
1119
|
+
if (depth === 0) {
|
|
1120
|
+
push(i);
|
|
1121
|
+
return { open, close: i, entries };
|
|
1122
|
+
}
|
|
1123
|
+
depth--;
|
|
1124
|
+
} else if (c === "," && depth === 0) {
|
|
1125
|
+
push(i);
|
|
1126
|
+
from = i + 1;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
return undefined;
|
|
1130
|
+
}
|
|
@@ -2,8 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { describe, expect, it } from "bun:test";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
newDashboardProblem,
|
|
7
|
+
newDashboardSource,
|
|
8
|
+
slugFor,
|
|
9
|
+
} from "./newDashboard";
|
|
6
10
|
import { openDocument } from "./testing/fixtures";
|
|
11
|
+
import { queryTile } from "./testing/fixtures";
|
|
7
12
|
|
|
8
13
|
describe("a new dashboard", () => {
|
|
9
14
|
it("names its file after its title", () => {
|
|
@@ -31,10 +36,49 @@ describe("a new dashboard", () => {
|
|
|
31
36
|
expect(document.tiles.map((tile) => tile.name)).toEqual([
|
|
32
37
|
"by_category_tile",
|
|
33
38
|
]);
|
|
34
|
-
expect(document
|
|
39
|
+
expect(queryTile(document, 0).declaration).toEqual({
|
|
35
40
|
kind: "reference",
|
|
36
41
|
from: "by_category",
|
|
37
42
|
});
|
|
38
43
|
expect(document.tiles[0].colspan).toBe(6);
|
|
39
44
|
});
|
|
45
|
+
|
|
46
|
+
it("trims the title once, and refuses a source named like a keyword", () => {
|
|
47
|
+
const base = {
|
|
48
|
+
title: " Sales ",
|
|
49
|
+
modelPath: "m.malloy",
|
|
50
|
+
source: "s",
|
|
51
|
+
view: "v",
|
|
52
|
+
};
|
|
53
|
+
expect(newDashboardSource(base)).toContain('title="Sales"');
|
|
54
|
+
expect(newDashboardProblem({ ...base, source: "date" })).toContain(
|
|
55
|
+
"cannot be written",
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("refuses a title, source or view it cannot write, instead of writing a broken file", () => {
|
|
60
|
+
const base = {
|
|
61
|
+
title: "Sales",
|
|
62
|
+
modelPath: "models/storefront.malloy",
|
|
63
|
+
source: "order_items",
|
|
64
|
+
view: "by_category",
|
|
65
|
+
};
|
|
66
|
+
expect(newDashboardProblem(base)).toBeUndefined();
|
|
67
|
+
expect(newDashboardProblem({ ...base, title: "a\nb" })).toContain(
|
|
68
|
+
"one line",
|
|
69
|
+
);
|
|
70
|
+
expect(newDashboardProblem({ ...base, title: "# authorize" })).toContain(
|
|
71
|
+
"access-control",
|
|
72
|
+
);
|
|
73
|
+
expect(newDashboardProblem({ ...base, source: "order items" })).toContain(
|
|
74
|
+
"source name",
|
|
75
|
+
);
|
|
76
|
+
expect(newDashboardProblem({ ...base, view: "v\n" })).toContain("view");
|
|
77
|
+
expect(
|
|
78
|
+
newDashboardProblem({ ...base, modelPath: 'a".malloy' }),
|
|
79
|
+
).toContain("model path");
|
|
80
|
+
expect(() => newDashboardSource({ ...base, title: "a\nb" })).toThrow(
|
|
81
|
+
"one line",
|
|
82
|
+
);
|
|
83
|
+
});
|
|
40
84
|
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { annotationTextProblem } from "./annotationText";
|
|
5
|
+
import { isBareName } from "../../utils/malloyText";
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* A new dashboard file, the way the builder would have written it: the
|
|
6
9
|
* dashboard-declared-givens convention with no givens yet, one extension of
|
|
@@ -21,11 +24,35 @@ export function slugFor(title: string): string {
|
|
|
21
24
|
return title
|
|
22
25
|
.toLowerCase()
|
|
23
26
|
.replace(/[^a-z0-9]+/g, "-")
|
|
24
|
-
.replace(
|
|
27
|
+
.replace(/^-|-$/g, "")
|
|
25
28
|
.slice(0, 80);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
|
|
31
|
+
/** Why this dashboard cannot be written as a file, or undefined when it can. */
|
|
32
|
+
export function newDashboardProblem({
|
|
33
|
+
title,
|
|
34
|
+
modelPath,
|
|
35
|
+
source,
|
|
36
|
+
view,
|
|
37
|
+
}: NewDashboard): string | undefined {
|
|
38
|
+
for (const [what, name] of [
|
|
39
|
+
["source", source],
|
|
40
|
+
["view", view],
|
|
41
|
+
] as const)
|
|
42
|
+
if (!isBareName(name))
|
|
43
|
+
return `The ${what} name ${JSON.stringify(name)} cannot be written as a Malloy name.`;
|
|
44
|
+
if (/["\\\r\n]/.test(modelPath))
|
|
45
|
+
return `The model path ${JSON.stringify(modelPath)} cannot be written into an import.`;
|
|
46
|
+
return annotationTextProblem("title", title);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function newDashboardSource(dashboard: NewDashboard): string {
|
|
50
|
+
const problem = newDashboardProblem(dashboard);
|
|
51
|
+
if (problem) throw new Error(problem);
|
|
52
|
+
return writeNewDashboard(dashboard);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function writeNewDashboard({
|
|
29
56
|
title,
|
|
30
57
|
modelPath,
|
|
31
58
|
source,
|
|
@@ -33,7 +60,7 @@ export function newDashboardSource({
|
|
|
33
60
|
}: NewDashboard): string {
|
|
34
61
|
const extension = `${source}_tiles`;
|
|
35
62
|
const tile = `${view}_tile`;
|
|
36
|
-
const quoted = `"${title.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
63
|
+
const quoted = `"${title.trim().replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
37
64
|
return [
|
|
38
65
|
"##! experimental.givens",
|
|
39
66
|
`## artifact { title=${quoted} tiles=["${extension} -> ${tile}"] } dashboard { columns=12 }`,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useContext,
|
|
7
|
+
useEffect,
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
useRef,
|
|
10
|
+
type MutableRefObject,
|
|
11
|
+
} from "react";
|
|
12
|
+
|
|
13
|
+
/** Where an inline field tells the builder it holds text that is not in the document yet. */
|
|
14
|
+
export interface OpenDraftSink {
|
|
15
|
+
setDirty: (dirty: boolean) => void;
|
|
16
|
+
/** Holds a function that commits the open draft; true when it did, false when the draft was refused. */
|
|
17
|
+
commitRef: MutableRefObject<(() => boolean) | undefined>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const OpenDraftContext = createContext<OpenDraftSink | undefined>(
|
|
21
|
+
undefined,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
/** Reports an open field's draft as unsaved while `dirty`, and lets a save commit it first. */
|
|
25
|
+
export function useReportOpenDraft(dirty: boolean, commit: () => boolean) {
|
|
26
|
+
const sink = useContext(OpenDraftContext);
|
|
27
|
+
const latestCommit = useRef(commit);
|
|
28
|
+
latestCommit.current = commit;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!sink || !dirty) return;
|
|
31
|
+
const mine = () => latestCommit.current();
|
|
32
|
+
sink.commitRef.current = mine;
|
|
33
|
+
return () => {
|
|
34
|
+
if (sink.commitRef.current === mine)
|
|
35
|
+
sink.commitRef.current = undefined;
|
|
36
|
+
};
|
|
37
|
+
}, [sink, dirty]);
|
|
38
|
+
// A field that never held a dirty draft stays silent, or mounting would clear another field's.
|
|
39
|
+
const reported = useRef(false);
|
|
40
|
+
// Layout effects, so the flag settles inside the click: a passive effect's update renders a task later, after a host's leave guard may have read it.
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
if (!dirty && !reported.current) return;
|
|
43
|
+
reported.current = dirty;
|
|
44
|
+
sink?.setDirty(dirty);
|
|
45
|
+
}, [sink, dirty]);
|
|
46
|
+
useLayoutEffect(
|
|
47
|
+
() => () => {
|
|
48
|
+
if (reported.current) sink?.setDirty(false);
|
|
49
|
+
},
|
|
50
|
+
[sink],
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import type { QueryTile } from "./document";
|
|
6
|
+
import { previewTileQuery } from "./preview";
|
|
7
|
+
import { openDocument, queryTile, spliced } from "./testing/fixtures";
|
|
8
|
+
|
|
9
|
+
const NONE =
|
|
10
|
+
"# -line_chart -bar_chart -big_value -scatter_chart -shape_map -segment_map -viz";
|
|
11
|
+
|
|
12
|
+
const SHAPES = `## artifact { title="T" tiles=["a -> inl", "a -> comp", "a -> pipe", "a -> chain", "a -> paren", "a -> ref"] }
|
|
13
|
+
import "../m.malloy"
|
|
14
|
+
|
|
15
|
+
source: a is one extend {
|
|
16
|
+
view: inl is { group_by: x }
|
|
17
|
+
view: comp is { group_by: x } + { limit: 3 }
|
|
18
|
+
view: pipe is v -> { select: x }
|
|
19
|
+
view: chain is v + { limit: 3 } + { limit: 4 }
|
|
20
|
+
view: paren is (v + { limit: 3 }) + { limit: 4 }
|
|
21
|
+
view: ref is v
|
|
22
|
+
}`;
|
|
23
|
+
|
|
24
|
+
describe("the Default chart preview, for the shapes a real dashboard reads", () => {
|
|
25
|
+
it("clears the saved chart only where the body has no named base view", async () => {
|
|
26
|
+
const document = await openDocument(SHAPES);
|
|
27
|
+
const annotations = Object.fromEntries(
|
|
28
|
+
document.tiles.map((tile) => [
|
|
29
|
+
tile.name,
|
|
30
|
+
previewTileQuery(
|
|
31
|
+
document,
|
|
32
|
+
{ ...tile, chart: "default" } as QueryTile,
|
|
33
|
+
new Set(),
|
|
34
|
+
).annotation,
|
|
35
|
+
]),
|
|
36
|
+
);
|
|
37
|
+
expect(annotations).toEqual({
|
|
38
|
+
inl: NONE,
|
|
39
|
+
comp: NONE,
|
|
40
|
+
pipe: NONE,
|
|
41
|
+
chain: undefined,
|
|
42
|
+
paren: undefined,
|
|
43
|
+
ref: undefined,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("a filter field is read and written as it stands", () => {
|
|
49
|
+
const FILTERS = `##! experimental.givens
|
|
50
|
+
## artifact { title="T" tiles=["a -> x", "a -> y", "a -> z"] }
|
|
51
|
+
import "../m.malloy"
|
|
52
|
+
|
|
53
|
+
source: a is one extend {
|
|
54
|
+
view: x is v + { where: created_at.year ~ $Y }
|
|
55
|
+
view: y is v + { where: \`category\` ~ $C }
|
|
56
|
+
view: z is v + { where: lower(\`date\`) ~ $A }
|
|
57
|
+
}`;
|
|
58
|
+
|
|
59
|
+
it("keeps dotted paths and expressions verbatim, and a redundant quote untouched", async () => {
|
|
60
|
+
const document = await openDocument(FILTERS);
|
|
61
|
+
expect(
|
|
62
|
+
document.tiles.map(
|
|
63
|
+
(t) =>
|
|
64
|
+
queryTile(document, document.tiles.indexOf(t)).filters?.[0]
|
|
65
|
+
?.field,
|
|
66
|
+
),
|
|
67
|
+
).toEqual(["created_at.year", "category", "lower(`date`)"]);
|
|
68
|
+
const out = await spliced(FILTERS, (d) => {
|
|
69
|
+
for (const tile of d.tiles) tile.colspan = 4;
|
|
70
|
+
});
|
|
71
|
+
expect(out).toContain("where: created_at.year ~ $Y");
|
|
72
|
+
expect(out).toContain("where: `category` ~ $C");
|
|
73
|
+
expect(out).toContain("where: lower(`date`) ~ $A");
|
|
74
|
+
});
|
|
75
|
+
});
|