@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
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Stack,
|
|
9
|
-
TextField,
|
|
10
|
-
Typography,
|
|
11
|
-
} from "@mui/material";
|
|
4
|
+
import AdsClickIcon from "@mui/icons-material/AdsClick";
|
|
5
|
+
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
|
6
|
+
import { Button, Popover, Stack, Typography } from "@mui/material";
|
|
7
|
+
import { useEffect, useId, useRef } from "react";
|
|
12
8
|
import { useDraft } from "./useDraft";
|
|
9
|
+
import { dangerTextColor } from "../../theme/motion";
|
|
13
10
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
14
|
-
import type {
|
|
11
|
+
import type { CatalogView } from "./catalog";
|
|
12
|
+
import { isQueryTile, type DashboardTile, type QueryTile } from "./document";
|
|
13
|
+
import { ChartPicker } from "./ChartPicker";
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* A tile's own settings, on the tile: a popover off its menu button, so
|
|
18
|
-
* editing it never means scrolling away from it. Its
|
|
19
|
-
*
|
|
17
|
+
* editing it never means scrolling away from it. Its chart, clickable cells
|
|
18
|
+
* and removal; its width is set by dragging its right edge; its title and subtitle are edited on the tile. Its row is set by dragging it — a drop
|
|
20
19
|
* into the empty end of a row is what "start a new row" means — and its card
|
|
21
20
|
* is the reader's to decide, so neither is a toggle here. Which controls it
|
|
22
21
|
* answers to is not here either: filters are configured in one place, the
|
|
23
|
-
* strip under the header.
|
|
22
|
+
* strip under the header. A chart pick commits at once, so the tile redraws
|
|
23
|
+
* under the open menu (`useDraft`'s `apply`).
|
|
24
|
+
*
|
|
25
|
+
* A text tile has only Remove: its words are written on the tile itself.
|
|
24
26
|
*/
|
|
25
27
|
export interface TileMenuProps {
|
|
26
28
|
anchor: HTMLElement | null;
|
|
@@ -30,31 +32,62 @@ export interface TileMenuProps {
|
|
|
30
32
|
onCommit: (next: DashboardTile) => void;
|
|
31
33
|
/** Take the tile off the dashboard. Offered on every tile: order is this file's. */
|
|
32
34
|
onRemove: () => void;
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
+
/** Why removing is refused, shown beside a Remove that stays focusable; absent when it is allowed. */
|
|
36
|
+
removeBlocked?: string;
|
|
35
37
|
/** Open the clickable-cells window for this tile's source. */
|
|
36
38
|
onDrills: () => void;
|
|
39
|
+
/** The catalog's view the tile shows, when the catalog knows it: what decides which charts are offered. */
|
|
40
|
+
view?: Pick<CatalogView, "chart" | "aggregateOnly">;
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
const customChart = (lines: string[] | undefined) =>
|
|
44
|
+
lines && lines.length === 1
|
|
45
|
+
? `This tile's chart line (${lines[0]}) is not one the builder models, so its chart cannot be changed here.`
|
|
46
|
+
: `This tile has ${lines?.length ?? "several"} chart lines${lines ? ` (${lines.join(" and ")})` : ""}, so its chart cannot be changed here.`;
|
|
47
|
+
const INHERITED_CHART =
|
|
48
|
+
"This tile's view is declared on its source, so its chart is set in the model.";
|
|
49
|
+
|
|
39
50
|
export function TileMenu({
|
|
40
51
|
anchor,
|
|
41
52
|
tile,
|
|
42
53
|
onClose,
|
|
43
54
|
onCommit,
|
|
44
55
|
onRemove,
|
|
45
|
-
|
|
56
|
+
removeBlocked,
|
|
46
57
|
onDrills,
|
|
58
|
+
view,
|
|
47
59
|
}: TileMenuProps) {
|
|
60
|
+
const removeReasonId = useId();
|
|
48
61
|
const { theme } = usePublisherTheme();
|
|
49
|
-
const { draft,
|
|
62
|
+
const { draft, apply, close, discard } = useDraft(
|
|
50
63
|
tile,
|
|
51
64
|
anchor !== null,
|
|
52
65
|
onCommit,
|
|
53
66
|
onClose,
|
|
54
67
|
);
|
|
55
68
|
|
|
69
|
+
const query = draft !== undefined && isQueryTile(draft) ? draft : undefined;
|
|
56
70
|
const editable =
|
|
57
|
-
|
|
71
|
+
query !== undefined && query.declaration.kind !== "inherited";
|
|
72
|
+
// The draft is a query tile whenever the controls that call this are shown.
|
|
73
|
+
// Committed at once, so the tile redraws in the new chart while the menu is
|
|
74
|
+
// still open rather than when it closes.
|
|
75
|
+
const applyQuery = (change: (t: QueryTile) => void) =>
|
|
76
|
+
apply((t) => {
|
|
77
|
+
if (isQueryTile(t)) change(t);
|
|
78
|
+
});
|
|
79
|
+
// The chart as the menu opened on it: each pick commits, so the tile prop
|
|
80
|
+
// moves with them, and "back to where it started" means where the menu
|
|
81
|
+
// started.
|
|
82
|
+
const openedChart = useRef<QueryTile["chart"]>(undefined);
|
|
83
|
+
const opened = anchor !== null;
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (opened)
|
|
86
|
+
openedChart.current =
|
|
87
|
+
tile && isQueryTile(tile) ? tile.chart : undefined;
|
|
88
|
+
// Only on opening: the tile changes under every pick.
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
}, [opened]);
|
|
58
91
|
|
|
59
92
|
return (
|
|
60
93
|
<Popover
|
|
@@ -71,107 +104,77 @@ export function TileMenu({
|
|
|
71
104
|
variant="overline"
|
|
72
105
|
sx={{ color: theme.tileTitle, lineHeight: 1.5 }}
|
|
73
106
|
>
|
|
74
|
-
{
|
|
107
|
+
{query
|
|
108
|
+
? `${query.source} → ${query.name}`
|
|
109
|
+
: `Text · ${draft.name}`}
|
|
75
110
|
</Typography>
|
|
76
111
|
|
|
77
|
-
{editable
|
|
112
|
+
{query && editable && (
|
|
78
113
|
<>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
else t.subtitle = v;
|
|
114
|
+
<ChartPicker
|
|
115
|
+
state={query.chart ?? "default"}
|
|
116
|
+
view={view}
|
|
117
|
+
cellLabel={`${query.source} ${query.name}`}
|
|
118
|
+
{...(query.chart === "custom"
|
|
119
|
+
? { disabledReason: customChart(query.chartLines) }
|
|
120
|
+
: {})}
|
|
121
|
+
onChange={(next) =>
|
|
122
|
+
applyQuery((t) => {
|
|
123
|
+
const was = openedChart.current;
|
|
124
|
+
// Back to where it started is no edit, so the draft must not differ from the tile.
|
|
125
|
+
if (next === (was ?? "default")) {
|
|
126
|
+
if (was === undefined) delete t.chart;
|
|
127
|
+
else t.chart = was;
|
|
128
|
+
delete t.chartCarried;
|
|
129
|
+
} else {
|
|
130
|
+
t.chart = next;
|
|
131
|
+
if (view)
|
|
132
|
+
t.chartCarried = view.chart
|
|
133
|
+
? [view.chart]
|
|
134
|
+
: [];
|
|
135
|
+
else delete t.chartCarried;
|
|
136
|
+
}
|
|
103
137
|
})
|
|
104
138
|
}
|
|
105
139
|
/>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
140
|
+
</>
|
|
141
|
+
)}
|
|
142
|
+
{query && !editable && (
|
|
143
|
+
<>
|
|
144
|
+
<Typography
|
|
145
|
+
variant="body2"
|
|
146
|
+
sx={{ color: theme.tileTitle }}
|
|
112
147
|
>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
["⅓", 3],
|
|
124
|
-
["¼", 4],
|
|
125
|
-
] as const
|
|
126
|
-
).map(([label, share]) => {
|
|
127
|
-
const span = Math.max(
|
|
128
|
-
1,
|
|
129
|
-
Math.round(columns / share),
|
|
130
|
-
);
|
|
131
|
-
const active = (draft.colspan ?? 1) === span;
|
|
132
|
-
return (
|
|
133
|
-
<Button
|
|
134
|
-
key={label}
|
|
135
|
-
size="small"
|
|
136
|
-
variant={active ? "contained" : "outlined"}
|
|
137
|
-
aria-label={`Width ${label}`}
|
|
138
|
-
aria-pressed={active}
|
|
139
|
-
onClick={() =>
|
|
140
|
-
patch((t) => {
|
|
141
|
-
t.colspan = span;
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
sx={{ minWidth: 40, px: 1 }}
|
|
145
|
-
>
|
|
146
|
-
{label}
|
|
147
|
-
</Button>
|
|
148
|
-
);
|
|
149
|
-
})}
|
|
150
|
-
</Stack>
|
|
148
|
+
Declared on its source, so its title and layout are set
|
|
149
|
+
in the model. It can still be moved.
|
|
150
|
+
</Typography>
|
|
151
|
+
<ChartPicker
|
|
152
|
+
state="default"
|
|
153
|
+
view={view}
|
|
154
|
+
cellLabel={`${query.source} ${query.name}`}
|
|
155
|
+
disabledReason={INHERITED_CHART}
|
|
156
|
+
onChange={() => {}}
|
|
157
|
+
/>
|
|
151
158
|
</>
|
|
152
|
-
) : (
|
|
153
|
-
<Typography variant="body2" sx={{ color: theme.tileTitle }}>
|
|
154
|
-
Declared on its source, so its title and layout are set in
|
|
155
|
-
the model. It can still be moved.
|
|
156
|
-
</Typography>
|
|
157
159
|
)}
|
|
158
|
-
{
|
|
160
|
+
{query?.declaration.kind === "opaque" && (
|
|
159
161
|
<Typography variant="body2" sx={{ color: theme.tileTitle }}>
|
|
160
|
-
Its body is {
|
|
162
|
+
Its body is {query.declaration.why}, so a filter has no
|
|
161
163
|
single place to go. Everything else here is editable.
|
|
162
164
|
</Typography>
|
|
163
165
|
)}
|
|
164
|
-
<Divider />
|
|
165
166
|
<Stack direction="row" sx={{ justifyContent: "space-between" }}>
|
|
166
167
|
{editable ? (
|
|
167
168
|
<Button
|
|
168
169
|
size="small"
|
|
170
|
+
startIcon={<AdsClickIcon />}
|
|
171
|
+
aria-haspopup="dialog"
|
|
169
172
|
onClick={() => {
|
|
170
173
|
close();
|
|
171
174
|
onDrills();
|
|
172
175
|
}}
|
|
173
176
|
>
|
|
174
|
-
|
|
177
|
+
Drill
|
|
175
178
|
</Button>
|
|
176
179
|
) : (
|
|
177
180
|
<span />
|
|
@@ -179,14 +182,39 @@ export function TileMenu({
|
|
|
179
182
|
<Button
|
|
180
183
|
color="error"
|
|
181
184
|
size="small"
|
|
185
|
+
startIcon={<DeleteOutlineIcon />}
|
|
186
|
+
// aria-disabled, not disabled, so the reason stays reachable by keyboard.
|
|
187
|
+
aria-disabled={removeBlocked !== undefined || undefined}
|
|
188
|
+
aria-describedby={
|
|
189
|
+
removeBlocked !== undefined ? removeReasonId : undefined
|
|
190
|
+
}
|
|
191
|
+
disableRipple={removeBlocked !== undefined}
|
|
192
|
+
sx={(muiTheme) => ({
|
|
193
|
+
// The host's destructive red (its error palette's
|
|
194
|
+
// deeper shade), so a host themes it rather than this.
|
|
195
|
+
color: dangerTextColor(muiTheme),
|
|
196
|
+
...(removeBlocked !== undefined
|
|
197
|
+
? { opacity: 0.5, cursor: "default" }
|
|
198
|
+
: {}),
|
|
199
|
+
})}
|
|
182
200
|
onClick={() => {
|
|
201
|
+
if (removeBlocked !== undefined) return;
|
|
183
202
|
discard();
|
|
184
203
|
onRemove();
|
|
185
204
|
}}
|
|
186
205
|
>
|
|
187
|
-
|
|
206
|
+
Delete
|
|
188
207
|
</Button>
|
|
189
208
|
</Stack>
|
|
209
|
+
{removeBlocked !== undefined && (
|
|
210
|
+
<Typography
|
|
211
|
+
id={removeReasonId}
|
|
212
|
+
variant="caption"
|
|
213
|
+
sx={{ color: theme.tileTitle }}
|
|
214
|
+
>
|
|
215
|
+
{removeBlocked}
|
|
216
|
+
</Typography>
|
|
217
|
+
)}
|
|
190
218
|
</Stack>
|
|
191
219
|
)}
|
|
192
220
|
</Popover>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { AUTHORIZE_TAG_LIKE as SERVER_AUTHORIZE_TAG_LIKE } from "../../../../server/src/service/authorize";
|
|
6
|
+
import { annotationTextProblem, AUTHORIZE_TAG_LIKE } from "./annotationText";
|
|
7
|
+
|
|
8
|
+
describe("annotationTextProblem", () => {
|
|
9
|
+
it("is the server's pattern, character for character", () => {
|
|
10
|
+
expect(AUTHORIZE_TAG_LIKE).toBe(SERVER_AUTHORIZE_TAG_LIKE);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("refuses a line break and what reads as an access-control tag", () => {
|
|
14
|
+
expect(annotationTextProblem("tile label", "a\nb")).toContain(
|
|
15
|
+
"tile label is one line",
|
|
16
|
+
);
|
|
17
|
+
expect(annotationTextProblem("tile label", "a\rb")).toContain("one line");
|
|
18
|
+
for (const text of [
|
|
19
|
+
"# authorize",
|
|
20
|
+
"x ##(row_authorize) y",
|
|
21
|
+
"#| access_filter",
|
|
22
|
+
])
|
|
23
|
+
expect(annotationTextProblem("tile label", text)).toContain(
|
|
24
|
+
"access-control",
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("accepts ordinary titles", () => {
|
|
29
|
+
expect(
|
|
30
|
+
annotationTextProblem("tile label", "Revenue (authorized) by region"),
|
|
31
|
+
).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/** A copy of the server's `AUTHORIZE_TAG_LIKE`, kept in step by a parity spec; the server's caller guard reads it anywhere outside markdown and text prose, and a tag value or `#"` caption is not prose. */
|
|
5
|
+
export const AUTHORIZE_TAG_LIKE = String.raw`##?\|?[ \t]*(?:[([{<][ \t]*)?(?:(?:(?:row|source)[-_]?)?authorize|access[-_]?filter)(?=[)\]}>]|[ \t]|$)`;
|
|
6
|
+
|
|
7
|
+
/** Why `text` cannot be written into a tag value or a `#"` note (`what` names it), or undefined when it can. */
|
|
8
|
+
export function annotationTextProblem(
|
|
9
|
+
what: string,
|
|
10
|
+
text: string,
|
|
11
|
+
): string | undefined {
|
|
12
|
+
if (/[\r\n]/.test(text))
|
|
13
|
+
return `A ${what} is one line; it cannot hold a line break.`;
|
|
14
|
+
if (new RegExp(AUTHORIZE_TAG_LIKE, "iu").test(text))
|
|
15
|
+
return `A ${what} cannot contain what reads as an access-control tag (authorize, row_authorize, source_authorize or access_filter).`;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { isTextTile, type DashboardDocument } from "./document";
|
|
6
|
+
import { artifactTag } from "../../utils/malloyText";
|
|
7
|
+
import {
|
|
8
|
+
spliceDashboardDocument,
|
|
9
|
+
spliceFailed,
|
|
10
|
+
syntaxErrors,
|
|
11
|
+
} from "./spliceDocument";
|
|
12
|
+
import { openDocument } from "./testing/fixtures";
|
|
13
|
+
|
|
14
|
+
const BLOCK = `##! experimental.givens
|
|
15
|
+
##| artifact { kind=notebook title="Review"
|
|
16
|
+
tiles=[
|
|
17
|
+
intro { kind=text },
|
|
18
|
+
"a_tiles -> overview",
|
|
19
|
+
"a_tiles -> detail"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|##
|
|
23
|
+
import { a } from "../m.malloy"
|
|
24
|
+
|
|
25
|
+
##|(markdown) intro
|
|
26
|
+
Welcome.
|
|
27
|
+
|##
|
|
28
|
+
|
|
29
|
+
source: a_tiles is a extend {
|
|
30
|
+
view: overview is by_cat
|
|
31
|
+
view: detail is by_day
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
const SINGLE = BLOCK.replace(
|
|
36
|
+
/##\| artifact[\s\S]*?\|##\n/,
|
|
37
|
+
`## artifact { kind=notebook title="Review" tiles=[intro { kind=text }, "a_tiles -> overview", "a_tiles -> detail"] }\n`,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
async function writes(
|
|
41
|
+
source: string,
|
|
42
|
+
edit: (document: DashboardDocument) => void,
|
|
43
|
+
options?: { changeKind?: boolean },
|
|
44
|
+
): Promise<{ out: string; document: DashboardDocument }> {
|
|
45
|
+
const next = structuredClone(await openDocument(source));
|
|
46
|
+
edit(next);
|
|
47
|
+
const result = await spliceDashboardDocument(source, next, options);
|
|
48
|
+
if (spliceFailed(result)) throw new Error(result.reason);
|
|
49
|
+
expect(await syntaxErrors(result.source)).toEqual([]);
|
|
50
|
+
return { out: result.source, document: await openDocument(result.source) };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
describe("the artifact tag written as a ##| block", () => {
|
|
54
|
+
it("is found by line, with its closer outside its text", () => {
|
|
55
|
+
const tag = artifactTag(BLOCK.split("\n"));
|
|
56
|
+
expect(tag).toMatchObject({ from: 1, to: 8, block: true });
|
|
57
|
+
expect(tag?.text.startsWith("##| artifact {")).toBe(true);
|
|
58
|
+
expect(tag?.text).not.toContain("|##");
|
|
59
|
+
expect(artifactTag(SINGLE.split("\n"))).toMatchObject({
|
|
60
|
+
from: 1,
|
|
61
|
+
to: 1,
|
|
62
|
+
block: false,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("reads back to the same document as the one-line spelling", async () => {
|
|
67
|
+
const block = await openDocument(BLOCK);
|
|
68
|
+
const single = await openDocument(SINGLE);
|
|
69
|
+
expect(block).toEqual(single);
|
|
70
|
+
expect(block.kind).toBe("notebook");
|
|
71
|
+
expect(block.title).toBe("Review");
|
|
72
|
+
expect(block.tiles.map((t) => t.name)).toEqual([
|
|
73
|
+
"intro",
|
|
74
|
+
"overview",
|
|
75
|
+
"detail",
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("changes nothing for an edit that changes nothing", async () => {
|
|
80
|
+
expect((await writes(BLOCK, () => {})).out).toBe(BLOCK);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("reorders in place, one entry per line as it was written", async () => {
|
|
84
|
+
const { out, document } = await writes(BLOCK, (d) => {
|
|
85
|
+
d.tiles.reverse();
|
|
86
|
+
});
|
|
87
|
+
expect(out).toContain(
|
|
88
|
+
` tiles=[\n "a_tiles -> detail",\n "a_tiles -> overview",\n intro { kind=text }\n ]\n}\n|##\n`,
|
|
89
|
+
);
|
|
90
|
+
expect(document.tiles.map((t) => t.name)).toEqual([
|
|
91
|
+
"detail",
|
|
92
|
+
"overview",
|
|
93
|
+
"intro",
|
|
94
|
+
]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("removes an entry and its view, keeping the other lines", async () => {
|
|
98
|
+
const { out, document } = await writes(BLOCK, (d) => {
|
|
99
|
+
d.tiles = d.tiles.filter((t) => t.name !== "detail");
|
|
100
|
+
});
|
|
101
|
+
expect(out).toContain(
|
|
102
|
+
` tiles=[\n intro { kind=text },\n "a_tiles -> overview"\n ]\n}\n|##\n`,
|
|
103
|
+
);
|
|
104
|
+
expect(out).not.toContain("detail");
|
|
105
|
+
expect(document.tiles.map((t) => t.name)).toEqual(["intro", "overview"]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("adds an entry on a line of its own, and a text tile's entry with it", async () => {
|
|
109
|
+
const { out, document } = await writes(BLOCK, (d) => {
|
|
110
|
+
d.tiles.push({ kind: "text", name: "outro", markdown: "Bye." });
|
|
111
|
+
d.tiles.push({
|
|
112
|
+
name: "extra",
|
|
113
|
+
source: "a_tiles",
|
|
114
|
+
declaration: { kind: "reference", from: "by_x" },
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
expect(out).toContain(
|
|
118
|
+
` "a_tiles -> detail",\n outro { kind=text },\n "a_tiles -> extra"\n ]\n}\n|##\n`,
|
|
119
|
+
);
|
|
120
|
+
expect(out).toContain("##|(markdown) outro\nBye.\n|##\n");
|
|
121
|
+
expect(document.tiles.map((t) => t.name)).toEqual([
|
|
122
|
+
"intro",
|
|
123
|
+
"overview",
|
|
124
|
+
"detail",
|
|
125
|
+
"outro",
|
|
126
|
+
"extra",
|
|
127
|
+
]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("keeps the block when a text tile's width changes", async () => {
|
|
131
|
+
const { out } = await writes(BLOCK, (d) => {
|
|
132
|
+
const intro = d.tiles.find(isTextTile);
|
|
133
|
+
if (intro) intro.colspan = 6;
|
|
134
|
+
});
|
|
135
|
+
expect(out).toContain(` intro { kind=text colspan=6 },\n`);
|
|
136
|
+
expect(out).toContain(`##| artifact { kind=notebook title="Review"\n`);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("patches the title where it is, without collapsing the lines", async () => {
|
|
140
|
+
const { out, document } = await writes(BLOCK, (d) => {
|
|
141
|
+
d.title = "Renamed";
|
|
142
|
+
});
|
|
143
|
+
expect(out).toContain(
|
|
144
|
+
`##| artifact { kind=notebook title="Renamed"\n tiles=[\n`,
|
|
145
|
+
);
|
|
146
|
+
expect(document.title).toBe("Renamed");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("adds a property on its own line inside the block", async () => {
|
|
150
|
+
const { out, document } = await writes(BLOCK, (d) => {
|
|
151
|
+
d.autorun = false;
|
|
152
|
+
});
|
|
153
|
+
expect(out).toContain(
|
|
154
|
+
` "a_tiles -> detail"\n ]\n autorun=false\n}\n|##\n`,
|
|
155
|
+
);
|
|
156
|
+
expect(document.autorun).toBe(false);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("toggles the kind both ways, leaving the layout alone", async () => {
|
|
160
|
+
const asDashboard = await writes(
|
|
161
|
+
BLOCK,
|
|
162
|
+
(d) => {
|
|
163
|
+
d.kind = undefined;
|
|
164
|
+
d.columns = 12;
|
|
165
|
+
},
|
|
166
|
+
{ changeKind: true },
|
|
167
|
+
);
|
|
168
|
+
expect(asDashboard.out).toContain(
|
|
169
|
+
`##| artifact { title="Review"\n tiles=[\n`,
|
|
170
|
+
);
|
|
171
|
+
expect(asDashboard.document.kind).toBeUndefined();
|
|
172
|
+
expect(asDashboard.document.columns).toBe(12);
|
|
173
|
+
expect(asDashboard.out).toContain("dashboard { columns=12 }");
|
|
174
|
+
const back = await writes(
|
|
175
|
+
asDashboard.out,
|
|
176
|
+
(d) => {
|
|
177
|
+
d.kind = "notebook";
|
|
178
|
+
d.columns = undefined;
|
|
179
|
+
},
|
|
180
|
+
{ changeKind: true },
|
|
181
|
+
);
|
|
182
|
+
expect(back.document.kind).toBe("notebook");
|
|
183
|
+
expect(back.document.columns).toBeUndefined();
|
|
184
|
+
expect(back.out).not.toContain("dashboard {");
|
|
185
|
+
expect(back.out).toContain(`\n tiles=[\n intro { kind=text },\n`);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("adds, changes and removes starting givens inside the block", async () => {
|
|
189
|
+
const added = await writes(BLOCK, (d) => {
|
|
190
|
+
d.startingGivens = { REGION: "f'US'" };
|
|
191
|
+
});
|
|
192
|
+
expect(added.out).toContain(` ]\n givens { REGION="f'US'" }\n}\n|##\n`);
|
|
193
|
+
expect(added.document.startingGivens).toEqual({ REGION: "f'US'" });
|
|
194
|
+
|
|
195
|
+
const changed = await writes(added.out, (d) => {
|
|
196
|
+
d.startingGivens = { REGION: "f'US'", SINCE: "2023-01-01" };
|
|
197
|
+
});
|
|
198
|
+
expect(changed.out).toContain(
|
|
199
|
+
`givens { REGION="f'US'" SINCE="2023-01-01" }\n}\n|##\n`,
|
|
200
|
+
);
|
|
201
|
+
expect(changed.out.match(/givens \{/g)).toHaveLength(1);
|
|
202
|
+
expect(changed.document.startingGivens).toEqual({
|
|
203
|
+
REGION: "f'US'",
|
|
204
|
+
SINCE: "2023-01-01",
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const removed = await writes(changed.out, (d) => {
|
|
208
|
+
d.startingGivens = undefined;
|
|
209
|
+
});
|
|
210
|
+
expect(removed.out).toBe(BLOCK);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("takes autorun out again, leaving the block as it was", async () => {
|
|
214
|
+
const off = await writes(BLOCK, (d) => {
|
|
215
|
+
d.autorun = false;
|
|
216
|
+
});
|
|
217
|
+
const { out, document } = await writes(off.out, (d) => {
|
|
218
|
+
d.autorun = undefined;
|
|
219
|
+
});
|
|
220
|
+
expect(out).toBe(BLOCK);
|
|
221
|
+
expect(document.autorun).toBeUndefined();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("writes a description above the block and reads it back", async () => {
|
|
225
|
+
const { out, document } = await writes(BLOCK, (d) => {
|
|
226
|
+
d.description = "What this review covers.";
|
|
227
|
+
});
|
|
228
|
+
expect(document.description).toBe("What this review covers.");
|
|
229
|
+
expect(out).toContain(`##" What this review covers.\n`);
|
|
230
|
+
expect(out).toContain(
|
|
231
|
+
`##| artifact { kind=notebook title="Review"\n tiles=[\n`,
|
|
232
|
+
);
|
|
233
|
+
const cleared = await writes(out, (d) => {
|
|
234
|
+
d.description = undefined;
|
|
235
|
+
});
|
|
236
|
+
expect(cleared.out).toBe(BLOCK);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it("leaves a one-line tag one line through the same edits", async () => {
|
|
240
|
+
const { out } = await writes(SINGLE, (d) => {
|
|
241
|
+
d.tiles.reverse();
|
|
242
|
+
d.title = "Renamed";
|
|
243
|
+
});
|
|
244
|
+
expect(out.split("\n")[1]).toBe(
|
|
245
|
+
`## artifact { kind=notebook title="Renamed" tiles=["a_tiles -> detail", "a_tiles -> overview", intro { kind=text }] }`,
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { newNotebookSource } from "../DocumentCreate/newNotebook";
|
|
8
|
+
import { artifactTag, splitSourceLines } from "../../utils/malloyText";
|
|
9
|
+
|
|
10
|
+
// One case table for this reader and the server's; `artifact_tag_parity.spec.ts` there reads the same file.
|
|
11
|
+
const FIXTURE = path.join(import.meta.dir, "testing/artifactTagParity.json");
|
|
12
|
+
const { cases } = JSON.parse(fs.readFileSync(FIXTURE, "utf8")) as {
|
|
13
|
+
cases: {
|
|
14
|
+
name: string;
|
|
15
|
+
source: string;
|
|
16
|
+
tag: string[] | null;
|
|
17
|
+
sdk?: string[] | null;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
describe("artifactTag agrees with the server and the lexer", () => {
|
|
22
|
+
for (const { name, source, tag, sdk } of cases)
|
|
23
|
+
it(name, () => {
|
|
24
|
+
const found = artifactTag(splitSourceLines(source));
|
|
25
|
+
expect(
|
|
26
|
+
found ? found.text.split("\n").map((l) => l.trim()) : null,
|
|
27
|
+
).toEqual(sdk === undefined ? tag : sdk);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("newNotebookSource", () => {
|
|
32
|
+
it("writes the tag as a block whose closer has a line of its own", () => {
|
|
33
|
+
const lines = splitSourceLines(
|
|
34
|
+
newNotebookSource({
|
|
35
|
+
title: "Sales",
|
|
36
|
+
modelPath: "m.malloy",
|
|
37
|
+
source: "orders",
|
|
38
|
+
view: "by_brand",
|
|
39
|
+
}),
|
|
40
|
+
);
|
|
41
|
+
const tag = artifactTag(lines);
|
|
42
|
+
expect(tag?.block).toBe(true);
|
|
43
|
+
expect(lines[tag!.from]).not.toContain("|##");
|
|
44
|
+
expect(lines[tag!.to]).toBe("|##");
|
|
45
|
+
});
|
|
46
|
+
});
|