@malloy-publisher/sdk 0.9.7 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -17
- package/dist/{RenderedResult-CkUS04tl.es.js → RenderedResult-BHuJpdSn.es.js} +2 -2
- package/dist/{RenderedResult-qnpbr4tc.cjs.js → RenderedResult-Bw7EQc42.cjs.js} +1 -1
- package/dist/ServerProvider-B0dUY8be.cjs.js +1 -0
- package/dist/{ServerProvider-DnLLeXEX.es.js → ServerProvider-CQy4jVYK.es.js} +1602 -1074
- package/dist/builder/index.cjs.js +93 -93
- package/dist/builder/index.es.js +4630 -4562
- package/dist/builder-entry.d.ts +13 -12
- package/dist/client/api.d.ts +893 -104
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +125 -104
- package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
- package/dist/components/Dashboard/DashboardView.d.ts +1 -3
- package/dist/components/Dashboard/index.d.ts +0 -2
- package/dist/components/DocumentCreate/createDocument.d.ts +29 -9
- package/dist/components/DocumentCreate/documentPath.d.ts +21 -6
- package/dist/components/DocumentCreate/guards.d.ts +2 -3
- package/dist/components/DocumentCreate/index.d.ts +2 -3
- package/dist/components/DocumentCreate/newNotebook.d.ts +14 -5
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +6 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +52 -24
- package/dist/components/Loading.d.ts +1 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -3
- package/dist/components/Package/DataSchemaDialog.d.ts +26 -0
- package/dist/components/Package/NewDocumentDialog.d.ts +19 -10
- package/dist/components/Package/Package.d.ts +14 -9
- package/dist/components/Package/documentLocation.d.ts +66 -23
- package/dist/components/Package/index.d.ts +3 -2
- package/dist/components/Package/reportQueries.d.ts +8 -0
- package/dist/components/Package/useDocumentLocation.d.ts +36 -6
- package/dist/components/Package/useDraftLayout.d.ts +20 -0
- package/dist/components/Report/CellReport.d.ts +89 -0
- package/dist/components/Report/LinearReport.d.ts +18 -0
- package/dist/components/Report/Report.d.ts +62 -0
- package/dist/components/Report/index.d.ts +2 -0
- package/dist/components/Report/telemetry.d.ts +163 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.d.ts +5 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/EditorSurface.d.ts +10 -7
- package/dist/components/{DashboardBuilder/DashboardBuilder.d.ts → ReportBuilder/ReportBuilder.d.ts} +17 -8
- package/dist/components/{DashboardBuilder/DashboardEditor.d.ts → ReportBuilder/ReportEditor.d.ts} +41 -14
- package/dist/components/ReportBuilder/builderReport.d.ts +14 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/catalog.d.ts +8 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/document.d.ts +3 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/documentSession.d.ts +1 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/imports.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/malloyTree.d.ts +9 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/newDashboard.d.ts +7 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/readDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/readForEditor.d.ts +1 -1
- package/dist/components/ReportBuilder/reportTag.d.ts +52 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/spliceDocument.d.ts +1 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/useControlBindings.d.ts +2 -2
- package/dist/components/ReportBuilder/useEditorCatalog.d.ts +25 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/useHostCopy.d.ts +5 -3
- package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder/useDashboardEditor.d.ts → ReportBuilder/useReportEditor.d.ts} +3 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.d.ts +6 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/useTileEditing.d.ts +2 -2
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +8 -1
- package/dist/components/drill/useDrillSelf.d.ts +4 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/{Dashboard → legacy}/Dashboard.d.ts +15 -9
- package/dist/components/legacy/MalloynbCells.d.ts +13 -0
- package/dist/components/legacy/Notebook.d.ts +15 -0
- package/dist/components/{DashboardBuilder → legacy}/NotebookEditor.d.ts +3 -3
- package/dist/components/legacy/builderNames.d.ts +10 -0
- package/dist/components/legacy/index.d.ts +11 -0
- package/dist/components/legacy/kindAdapter.d.ts +11 -0
- package/dist/components/legacy/kindTypedDrafts.d.ts +10 -0
- package/dist/components/legacy/nameAlias.d.ts +44 -0
- package/dist/components/legacy/queryKeys.d.ts +8 -0
- package/dist/index.cjs.js +19 -19
- package/dist/index.es.js +8216 -7635
- package/dist/text/index.es.js +2 -2
- package/dist/{text-entry-CA0LZ1xL.es.js → text-entry-72YFLeNk.es.js} +10 -10
- package/dist/{useCompiledDocument-Bf72Ob5v.es.js → useCompiledDocument-1dgF5CC9.es.js} +4593 -4395
- package/dist/useCompiledDocument-BKyRnXmA.cjs.js +141 -0
- package/package.json +2 -2
- package/src/builder-entry.ts +32 -24
- package/src/components/Dashboard/DashboardTile.tsx +17 -0
- package/src/components/Dashboard/DashboardView.spec.tsx +0 -21
- package/src/components/Dashboard/DashboardView.tsx +8 -24
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +1 -4
- package/src/components/Dashboard/index.ts +0 -2
- package/src/components/DocumentCreate/createDocument.spec.ts +346 -53
- package/src/components/DocumentCreate/createDocument.ts +143 -63
- package/src/components/DocumentCreate/documentPath.ts +41 -12
- package/src/components/DocumentCreate/guards.ts +7 -15
- package/src/components/DocumentCreate/index.ts +3 -7
- package/src/components/DocumentCreate/newNotebook.spec.ts +113 -43
- package/src/components/DocumentCreate/newNotebook.ts +32 -10
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +130 -28
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +78 -40
- package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +426 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +57 -24
- package/src/components/Home/AddEnvironmentDialog.tsx +1 -1
- package/src/components/Home/Home.tsx +1 -1
- package/src/components/Loading.tsx +1 -1
- package/src/components/Model/SourcesExplorer.tsx +1 -1
- package/src/components/Notebook/NotebookCell.tsx +6 -5
- package/src/components/Notebook/cellKind.spec.ts +15 -7
- package/src/components/Package/ContentTypeIcon.tsx +16 -3
- package/src/components/Package/DataSchemaDialog.spec.tsx +85 -0
- package/src/components/Package/DataSchemaDialog.tsx +367 -0
- package/src/components/Package/NewDocumentDialog.spec.tsx +145 -88
- package/src/components/Package/NewDocumentDialog.tsx +93 -48
- package/src/components/Package/Package.agents.spec.tsx +76 -0
- package/src/components/Package/Package.artifacts.spec.tsx +79 -60
- package/src/components/Package/Package.create.spec.tsx +126 -112
- package/src/components/Package/Package.notebooks.spec.tsx +46 -27
- package/src/components/Package/Package.spec.tsx +43 -30
- package/src/components/Package/Package.tsx +217 -293
- package/src/components/Package/documentLocation.spec.ts +145 -50
- package/src/components/Package/documentLocation.ts +118 -39
- package/src/components/Package/index.ts +12 -3
- package/src/components/Package/reportQueries.ts +25 -0
- package/src/components/Package/useDocumentLocation.spec.ts +58 -0
- package/src/components/Package/useDocumentLocation.ts +90 -32
- package/src/components/Package/useDraftLayout.spec.tsx +143 -0
- package/src/components/Package/useDraftLayout.ts +81 -0
- package/src/components/Prose.spec.tsx +3 -3
- package/src/components/RenderedResult/RenderedResult.tsx +1 -1
- package/src/components/Report/CellReport.spec.tsx +155 -0
- package/src/components/{Notebook/Notebook.tsx → Report/CellReport.tsx} +178 -220
- package/src/components/Report/LinearReport.tsx +71 -0
- package/src/components/Report/Report.spec.tsx +238 -0
- package/src/components/Report/Report.telemetry.spec.tsx +292 -0
- package/src/components/Report/Report.tsx +277 -0
- package/src/components/Report/index.ts +12 -0
- package/src/components/Report/telemetry.spec.ts +90 -0
- package/src/components/Report/telemetry.ts +250 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.tsx +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.tsx +6 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.tsx +33 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/DrillDialog.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/EditorSurface.tsx +67 -107
- package/src/components/{DashboardBuilder → ReportBuilder}/FilterDialog.tsx +3 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.charts.spec.tsx → ReportBuilder/ReportBuilder.charts.spec.tsx} +4 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.exit.spec.tsx → ReportBuilder/ReportBuilder.exit.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.inline.spec.tsx → ReportBuilder/ReportBuilder.inline.spec.tsx} +4 -4
- package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +145 -0
- package/src/components/{DashboardBuilder/DashboardBuilder.notebook.spec.tsx → ReportBuilder/ReportBuilder.notebook.spec.tsx} +22 -21
- package/src/components/{DashboardBuilder/DashboardBuilder.openDraft.spec.tsx → ReportBuilder/ReportBuilder.openDraft.spec.tsx} +3 -3
- package/src/components/{DashboardBuilder/DashboardBuilder.sources.spec.tsx → ReportBuilder/ReportBuilder.sources.spec.tsx} +19 -8
- package/src/components/{DashboardBuilder/DashboardBuilder.spec.tsx → ReportBuilder/ReportBuilder.spec.tsx} +34 -34
- package/src/components/{DashboardBuilder/DashboardBuilder.textTiles.spec.tsx → ReportBuilder/ReportBuilder.textTiles.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.tsx → ReportBuilder/ReportBuilder.tsx} +46 -21
- package/src/components/{DashboardBuilder/DashboardEditor.authoritative.spec.tsx → ReportBuilder/ReportEditor.authoritative.spec.tsx} +28 -20
- package/src/components/{DashboardBuilder/DashboardEditor.emptyStart.spec.tsx → ReportBuilder/ReportEditor.emptyStart.spec.tsx} +19 -11
- package/src/components/{DashboardBuilder/DashboardEditor.filterTag.spec.tsx → ReportBuilder/ReportEditor.filterTag.spec.tsx} +7 -7
- package/src/components/{DashboardBuilder/DashboardEditor.notebook.spec.tsx → ReportBuilder/ReportEditor.notebook.spec.tsx} +70 -49
- package/src/components/{DashboardBuilder/DashboardEditor.package.spec.tsx → ReportBuilder/ReportEditor.package.spec.tsx} +52 -8
- package/src/components/{DashboardBuilder/DashboardEditor.resourceUri.spec.tsx → ReportBuilder/ReportEditor.resourceUri.spec.tsx} +50 -18
- package/src/components/{DashboardBuilder/DashboardEditor.spec.tsx → ReportBuilder/ReportEditor.spec.tsx} +65 -20
- package/src/components/{DashboardBuilder/DashboardEditor.textSource.spec.tsx → ReportBuilder/ReportEditor.textSource.spec.tsx} +6 -6
- package/src/components/{DashboardBuilder/DashboardEditor.tsx → ReportBuilder/ReportEditor.tsx} +92 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/addTile.compile.spec.ts +1 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/artifactBlock.spec.ts +21 -29
- package/src/components/ReportBuilder/builderReport.ts +53 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.spec.ts +28 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.ts +17 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/controls.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/document.ts +4 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.spec.ts +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.spec.ts +6 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.ts +8 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.chart.spec.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.convert.spec.ts +9 -13
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.read.spec.ts +15 -15
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.ts +7 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.ts +25 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.spec.ts +12 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.ts +11 -24
- package/src/components/{DashboardBuilder → ReportBuilder}/preview.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.spec.ts +64 -36
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.ts +33 -32
- package/src/components/ReportBuilder/readForEditor.spec.ts +96 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readForEditor.ts +3 -11
- package/src/components/ReportBuilder/reportTag.ts +108 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.imports.spec.ts +28 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.spec.ts +32 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.ts +37 -60
- package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.spec.ts +3 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/testing/artifactTagParity.json +2 -2
- package/src/components/ReportBuilder/testing/drillResolution.json +279 -0
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +125 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/textTiles.spec.ts +66 -143
- package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.ts +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/useControlBindings.ts +2 -2
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +156 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +119 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/useHostCopy.ts +7 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.ts +56 -35
- package/src/components/{DashboardBuilder/useDashboardEditor.spec.ts → ReportBuilder/useReportEditor.spec.ts} +6 -6
- package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts} +6 -17
- package/src/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.ts +36 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/useTileEditing.ts +2 -2
- package/src/components/ServerProvider.tsx +2 -0
- package/src/components/drill/resolveDrill.ts +9 -2
- package/src/components/drill/useDrill.tsx +1 -0
- package/src/components/drill/useDrillSelf.spec.tsx +60 -7
- package/src/components/drill/useDrillSelf.ts +29 -12
- package/src/components/index.ts +2 -1
- package/src/components/{Dashboard → legacy}/Dashboard.spec.tsx +1 -1
- package/src/components/{Dashboard → legacy}/Dashboard.tsx +40 -28
- package/src/components/legacy/MalloynbCells.tsx +88 -0
- package/src/components/{Notebook → legacy}/Notebook.served.spec.tsx +17 -13
- package/src/components/{Notebook → legacy}/Notebook.spec.tsx +24 -20
- package/src/components/legacy/Notebook.tsx +44 -0
- package/src/components/{DashboardBuilder → legacy}/NotebookEditor.tsx +7 -4
- package/src/components/legacy/builderNames.ts +25 -0
- package/src/components/legacy/index.ts +20 -0
- package/src/components/legacy/kindAdapter.ts +19 -0
- package/src/components/legacy/kindTypedDrafts.ts +34 -0
- package/src/components/legacy/nameAlias.spec.ts +124 -0
- package/src/components/legacy/nameAlias.ts +95 -0
- package/src/components/legacy/queryKeys.ts +26 -0
- package/src/hooks/useGivensState.spec.ts +9 -9
- package/src/mainEntry.spec.ts +1 -1
- package/src/textEntry.spec.ts +9 -9
- package/src/utils/formatting.spec.ts +5 -5
- package/src/utils/parsing.spec.ts +1 -1
- package/src/utils/parsing.ts +1 -1
- package/dist/ServerProvider-Gj-im5VD.cjs.js +0 -1
- package/dist/components/Dashboard/telemetry.d.ts +0 -73
- package/dist/components/DashboardBuilder/builderReport.d.ts +0 -13
- package/dist/components/DashboardBuilder/telemetry.d.ts +0 -43
- package/dist/components/DocumentCreate/events.d.ts +0 -10
- package/dist/components/Notebook/Notebook.d.ts +0 -52
- package/dist/components/Notebook/index.d.ts +0 -1
- package/dist/useCompiledDocument-tBejqZ7s.cjs.js +0 -142
- package/src/components/Dashboard/telemetry.ts +0 -75
- package/src/components/DashboardBuilder/builderReport.ts +0 -74
- package/src/components/DashboardBuilder/readForEditor.spec.ts +0 -80
- package/src/components/DashboardBuilder/telemetry.ts +0 -47
- package/src/components/DashboardBuilder/testing/documentKindRule.json +0 -40
- package/src/components/DocumentCreate/events.ts +0 -15
- package/src/components/Notebook/index.ts +0 -4
- /package/dist/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/ChartPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/DrillDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterStrip.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TextTileBody.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileFrame.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileMenu.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/annotationText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/changedTile.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/chartLine.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/controls.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/inlineEdit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/layout.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/loadMalloy.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/openDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/preview.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/sortable.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/spliceResult.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tagParse.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/inline.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/resize.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useExitGuard.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useFilterForm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileReorder.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileResize.d.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.render.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/FilterStrip.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineText.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TextTileBody.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileFrame.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileMenu.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/__test__/inventory.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/artifactTagParity.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/catalog.aggregate.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/controls.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/emptyStart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/inlineEdit.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/invariants.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/keepRowStructure.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/layout.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/moveIntoGap.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/openDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.shapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/scannerShapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.chart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceResult.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/statementExtent.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/inline.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/resize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/urlRenderTags.json +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.overlay.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.existing.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/withGaps.spec.ts +0 -0
- /package/src/components/{Notebook → legacy}/Notebook.layout.spec.tsx +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { useQueries } from "@tanstack/react-query";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import type { CompiledModel } from "../../client";
|
|
7
|
+
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
8
|
+
import type { ListedReport } from "../Package/documentLocation";
|
|
9
|
+
import { useServer } from "../ServerProvider";
|
|
10
|
+
import { buildCatalog, type PackageCatalog } from "./catalog";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The catalog a report's builder offers: every source the package publishes,
|
|
14
|
+
* less the reports (offering a report's own tile views would be circular) and
|
|
15
|
+
* this file. A tile runs against this file and may read only the package
|
|
16
|
+
* surface; files off it are not readable anyway (their model GET is 404).
|
|
17
|
+
*
|
|
18
|
+
* Nothing cached depends on the listing or on `modelPath`: the model listing
|
|
19
|
+
* is cached per package version, and each model under its own path, so the
|
|
20
|
+
* exclusions are applied on render and always follow the current listing and
|
|
21
|
+
* path. A listing that failed and then recovered, or a second report opened
|
|
22
|
+
* from the same cache, never inherits what a first read left out. The models
|
|
23
|
+
* excluded now are not fetched, so the builder never re-reads its own file or
|
|
24
|
+
* another report. Undefined until the listing and every model it needs have
|
|
25
|
+
* answered.
|
|
26
|
+
*/
|
|
27
|
+
export function useEditorCatalog({
|
|
28
|
+
environmentName,
|
|
29
|
+
packageName,
|
|
30
|
+
versionId,
|
|
31
|
+
modelPath,
|
|
32
|
+
reports,
|
|
33
|
+
reportsSettled,
|
|
34
|
+
}: {
|
|
35
|
+
environmentName: string;
|
|
36
|
+
packageName: string;
|
|
37
|
+
versionId?: string;
|
|
38
|
+
modelPath: string;
|
|
39
|
+
reports: readonly ListedReport[];
|
|
40
|
+
reportsSettled: boolean;
|
|
41
|
+
}): PackageCatalog | undefined {
|
|
42
|
+
const { apiClients, server } = useServer();
|
|
43
|
+
const { data: listed } = useQueryWithApiError<string[]>({
|
|
44
|
+
queryKey: [
|
|
45
|
+
"report-editor-models",
|
|
46
|
+
environmentName,
|
|
47
|
+
packageName,
|
|
48
|
+
versionId,
|
|
49
|
+
],
|
|
50
|
+
queryFn: async () =>
|
|
51
|
+
(
|
|
52
|
+
await apiClients.models.listModels(
|
|
53
|
+
environmentName,
|
|
54
|
+
packageName,
|
|
55
|
+
versionId,
|
|
56
|
+
)
|
|
57
|
+
).data.flatMap((m) => (m.path && !m.error ? [m.path] : [])),
|
|
58
|
+
});
|
|
59
|
+
const excluded = useMemo(
|
|
60
|
+
() =>
|
|
61
|
+
new Set([
|
|
62
|
+
modelPath,
|
|
63
|
+
...reports.flatMap((r) => (r.path ? [r.path] : [])),
|
|
64
|
+
]),
|
|
65
|
+
[reports, modelPath],
|
|
66
|
+
);
|
|
67
|
+
const wanted = useMemo(
|
|
68
|
+
() =>
|
|
69
|
+
reportsSettled
|
|
70
|
+
? (listed ?? []).filter((path) => !excluded.has(path))
|
|
71
|
+
: [],
|
|
72
|
+
[listed, excluded, reportsSettled],
|
|
73
|
+
);
|
|
74
|
+
const results = useQueries({
|
|
75
|
+
queries: wanted.map((path) => ({
|
|
76
|
+
// `useQueries` bypasses `useQueryWithApiError`, so the server is added here to keep two servers' caches apart.
|
|
77
|
+
queryKey: [
|
|
78
|
+
"report-editor-model",
|
|
79
|
+
environmentName,
|
|
80
|
+
packageName,
|
|
81
|
+
path,
|
|
82
|
+
versionId,
|
|
83
|
+
server,
|
|
84
|
+
],
|
|
85
|
+
queryFn: async () =>
|
|
86
|
+
(
|
|
87
|
+
await apiClients.models.getModel(
|
|
88
|
+
environmentName,
|
|
89
|
+
packageName,
|
|
90
|
+
path,
|
|
91
|
+
versionId,
|
|
92
|
+
)
|
|
93
|
+
).data,
|
|
94
|
+
retry: false,
|
|
95
|
+
})),
|
|
96
|
+
});
|
|
97
|
+
// One model that fails to load (a reload racing this fetch, say) costs the
|
|
98
|
+
// catalog that model's sources, not every suggestion.
|
|
99
|
+
const settled =
|
|
100
|
+
listed !== undefined &&
|
|
101
|
+
reportsSettled &&
|
|
102
|
+
results.every((r) => r.isSuccess || r.isError);
|
|
103
|
+
// `useQueries` returns a new array each render; its data changes when `dataUpdatedAt` does.
|
|
104
|
+
const version = results.map((r) => r.dataUpdatedAt).join();
|
|
105
|
+
return useMemo(
|
|
106
|
+
() =>
|
|
107
|
+
settled
|
|
108
|
+
? buildCatalog(
|
|
109
|
+
results.flatMap((r) =>
|
|
110
|
+
r.data ? [r.data as CompiledModel] : [],
|
|
111
|
+
),
|
|
112
|
+
excluded,
|
|
113
|
+
)
|
|
114
|
+
: undefined,
|
|
115
|
+
// `results` is read through `wanted` and `version`, which change when the set of models or any one's data does.
|
|
116
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
117
|
+
[settled, wanted, version, excluded],
|
|
118
|
+
);
|
|
119
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type Workspace,
|
|
9
9
|
} from "../DocumentStorage";
|
|
10
10
|
import { locatorFor } from "../DocumentCreate/documentPath";
|
|
11
|
-
import type {
|
|
11
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
12
12
|
import { chooseWorkspace, storageErrorMessage } from "./documentSession";
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -20,14 +20,16 @@ import { chooseWorkspace, storageErrorMessage } from "./documentSession";
|
|
|
20
20
|
*/
|
|
21
21
|
export function useHostCopy({
|
|
22
22
|
storage,
|
|
23
|
-
|
|
23
|
+
layout,
|
|
24
24
|
notebook,
|
|
25
25
|
environmentName,
|
|
26
26
|
packageName,
|
|
27
27
|
modelPath,
|
|
28
28
|
}: {
|
|
29
29
|
storage: DocumentStorage | undefined;
|
|
30
|
-
|
|
30
|
+
/** The layout the report opened with; a read finds the copy at its path whatever its layout. */
|
|
31
|
+
layout: ReportLayout;
|
|
32
|
+
/** The report opened linear: only an authoritative store's copy of it is read. */
|
|
31
33
|
notebook: boolean;
|
|
32
34
|
environmentName: string;
|
|
33
35
|
packageName: string;
|
|
@@ -65,7 +67,7 @@ export function useHostCopy({
|
|
|
65
67
|
const text = await storage
|
|
66
68
|
.getDocument(
|
|
67
69
|
locatorFor(
|
|
68
|
-
|
|
70
|
+
layout,
|
|
69
71
|
chosen.name,
|
|
70
72
|
environmentName,
|
|
71
73
|
packageName,
|
|
@@ -90,7 +92,7 @@ export function useHostCopy({
|
|
|
90
92
|
return () => {
|
|
91
93
|
stale = true;
|
|
92
94
|
};
|
|
93
|
-
}, [storage,
|
|
95
|
+
}, [storage, layout, notebook, environmentName, packageName, modelPath]);
|
|
94
96
|
|
|
95
97
|
return {
|
|
96
98
|
workspace,
|
|
@@ -6,10 +6,16 @@ import type { Workspace } from "../DocumentStorage";
|
|
|
6
6
|
import { now } from "../../utils/clock";
|
|
7
7
|
import type { DashboardDocument } from "./document";
|
|
8
8
|
import { readForEditor } from "./readForEditor";
|
|
9
|
-
import type {
|
|
9
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
10
|
+
import {
|
|
11
|
+
failureCategory,
|
|
12
|
+
withReportContext,
|
|
13
|
+
type ReportEventBody,
|
|
14
|
+
type ReportEventHandler,
|
|
15
|
+
} from "../Report/telemetry";
|
|
10
16
|
|
|
11
17
|
export const LEGACY_REFUSAL =
|
|
12
|
-
"a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy`
|
|
18
|
+
"a .malloynb notebook is read, not edited. Fix: rewrite it as a `.malloy` report to edit it here.";
|
|
13
19
|
|
|
14
20
|
const WITHHELD_REFUSAL =
|
|
15
21
|
"the server did not send this notebook's text, so there is nothing here to edit. Fix: edit the file in the package.";
|
|
@@ -42,9 +48,9 @@ export function useOpenedDocument({
|
|
|
42
48
|
fetchedAt,
|
|
43
49
|
packageSettled,
|
|
44
50
|
modelPath,
|
|
51
|
+
layout,
|
|
45
52
|
notebook,
|
|
46
53
|
noun,
|
|
47
|
-
refusedEvent,
|
|
48
54
|
legacyFormat,
|
|
49
55
|
textHeld,
|
|
50
56
|
startedAt,
|
|
@@ -63,16 +69,32 @@ export function useOpenedDocument({
|
|
|
63
69
|
/** Whether the package's fetch has succeeded and is not refetching. */
|
|
64
70
|
packageSettled: boolean;
|
|
65
71
|
modelPath: string;
|
|
72
|
+
/** The layout the host opened it as: what a failure before the text is read reports. */
|
|
73
|
+
layout: ReportLayout;
|
|
66
74
|
notebook: boolean;
|
|
67
75
|
noun: string;
|
|
68
|
-
refusedEvent: "notebook.open_refused" | "dashboard.open_refused";
|
|
69
76
|
legacyFormat: boolean;
|
|
70
77
|
/** The document is held as text by the host: there is no package file to fall back on. */
|
|
71
78
|
textHeld: boolean;
|
|
72
79
|
/** When the open was asked for, so "opened" can say how long it took. */
|
|
73
80
|
startedAt: MutableRefObject<number>;
|
|
74
|
-
onEventRef: MutableRefObject<
|
|
81
|
+
onEventRef: MutableRefObject<ReportEventHandler | undefined>;
|
|
75
82
|
}) {
|
|
83
|
+
// Read when an outcome lands, so neither is a reason to open again.
|
|
84
|
+
const targetRef = useRef({ path: modelPath, layout });
|
|
85
|
+
targetRef.current = { path: modelPath, layout };
|
|
86
|
+
const emitRef = useRef((body: ReportEventBody, opened?: ReportLayout) => {
|
|
87
|
+
try {
|
|
88
|
+
onEventRef.current?.(
|
|
89
|
+
withReportContext(body, {
|
|
90
|
+
...targetRef.current,
|
|
91
|
+
...(opened ? { layout: opened } : {}),
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
94
|
+
} catch {
|
|
95
|
+
// A sink that throws is the sink's problem, not the editor's.
|
|
96
|
+
}
|
|
97
|
+
});
|
|
76
98
|
// The host's copy is the record: the editor opens it, writes back to it,
|
|
77
99
|
// and never offers to "resume" it, because a record is not a pending edit.
|
|
78
100
|
const authoritative = workspace?.authoritative === true;
|
|
@@ -174,14 +196,15 @@ export function useOpenedDocument({
|
|
|
174
196
|
let stale = false;
|
|
175
197
|
const packageAtOpen = packageNowRef.current;
|
|
176
198
|
const latestAtOpen = latestRef.current;
|
|
177
|
-
void readForEditor(opening
|
|
199
|
+
void readForEditor(opening)
|
|
178
200
|
.then((result) => {
|
|
179
201
|
if (stale) return;
|
|
180
202
|
if (result.ok === false) {
|
|
181
203
|
setOpenError(result.reason);
|
|
182
|
-
|
|
183
|
-
type:
|
|
184
|
-
|
|
204
|
+
emitRef.current({
|
|
205
|
+
type: "report.load_failed",
|
|
206
|
+
surface: "edit",
|
|
207
|
+
category: "invalid",
|
|
185
208
|
});
|
|
186
209
|
return;
|
|
187
210
|
}
|
|
@@ -203,28 +226,26 @@ export function useOpenedDocument({
|
|
|
203
226
|
: {}),
|
|
204
227
|
generation: (previous?.generation ?? 0) + 1,
|
|
205
228
|
}));
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
: {
|
|
216
|
-
type: "dashboard.opened",
|
|
217
|
-
from: fromRef.current,
|
|
218
|
-
tiles: result.document.tiles.length,
|
|
219
|
-
durationMs: now() - startedAt.current,
|
|
220
|
-
},
|
|
229
|
+
emitRef.current(
|
|
230
|
+
{
|
|
231
|
+
type: "report.opened",
|
|
232
|
+
surface: "edit",
|
|
233
|
+
from: fromRef.current,
|
|
234
|
+
tiles: result.document.tiles.length,
|
|
235
|
+
durationMs: now() - startedAt.current,
|
|
236
|
+
},
|
|
237
|
+
result.document.layout,
|
|
221
238
|
);
|
|
222
239
|
})
|
|
223
240
|
.catch((error: unknown) => {
|
|
224
241
|
if (stale) return;
|
|
225
242
|
const reason = `Could not read the ${noun}: ${error instanceof Error ? error.message : String(error)}`;
|
|
226
243
|
setOpenError(reason);
|
|
227
|
-
|
|
244
|
+
emitRef.current({
|
|
245
|
+
type: "report.load_failed",
|
|
246
|
+
surface: "edit",
|
|
247
|
+
category: failureCategory(error),
|
|
248
|
+
});
|
|
228
249
|
});
|
|
229
250
|
return () => {
|
|
230
251
|
stale = true;
|
|
@@ -236,20 +257,19 @@ export function useOpenedDocument({
|
|
|
236
257
|
blockedOnRecord,
|
|
237
258
|
notebook,
|
|
238
259
|
noun,
|
|
239
|
-
refusedEvent,
|
|
240
260
|
textHeld,
|
|
241
261
|
// Refs, stable: read when the open lands, never a reason to open again.
|
|
242
262
|
startedAt,
|
|
243
|
-
onEventRef,
|
|
244
263
|
]);
|
|
245
264
|
|
|
246
265
|
useEffect(() => {
|
|
247
266
|
if (legacyFormat)
|
|
248
|
-
|
|
249
|
-
type: "
|
|
250
|
-
|
|
267
|
+
emitRef.current({
|
|
268
|
+
type: "report.load_failed",
|
|
269
|
+
surface: "edit",
|
|
270
|
+
category: "unsupported",
|
|
251
271
|
});
|
|
252
|
-
}, [legacyFormat
|
|
272
|
+
}, [legacyFormat]);
|
|
253
273
|
|
|
254
274
|
// The record is the only document a text source has, so it must exist and be one the host calls authoritative.
|
|
255
275
|
useEffect(() => {
|
|
@@ -274,11 +294,12 @@ export function useOpenedDocument({
|
|
|
274
294
|
useEffect(() => {
|
|
275
295
|
if (!withheld) return;
|
|
276
296
|
setOpenError(WITHHELD_REFUSAL);
|
|
277
|
-
|
|
278
|
-
type: "
|
|
279
|
-
|
|
297
|
+
emitRef.current({
|
|
298
|
+
type: "report.load_failed",
|
|
299
|
+
surface: "edit",
|
|
300
|
+
category: "forbidden",
|
|
280
301
|
});
|
|
281
|
-
}, [withheld
|
|
302
|
+
}, [withheld]);
|
|
282
303
|
|
|
283
304
|
// An explicit choice is a choice about the very text that would otherwise
|
|
284
305
|
// be held back, so it is never held.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { act, renderHook, waitFor } from "@testing-library/react";
|
|
5
5
|
import { describe, expect, it } from "bun:test";
|
|
6
6
|
import { openDocument } from "./testing/fixtures";
|
|
7
|
-
import {
|
|
7
|
+
import { useReportEditor } from "./useReportEditor";
|
|
8
8
|
import { queryTile } from "./testing/fixtures";
|
|
9
9
|
import { tileKey } from "./document";
|
|
10
10
|
|
|
@@ -27,11 +27,11 @@ const editor = async (
|
|
|
27
27
|
) => {
|
|
28
28
|
const document = await openDocument(source);
|
|
29
29
|
return renderHook(() =>
|
|
30
|
-
|
|
30
|
+
useReportEditor({ source, document, ...(onSave ? { onSave } : {}) }),
|
|
31
31
|
);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
describe("
|
|
34
|
+
describe("useReportEditor: editing", () => {
|
|
35
35
|
it("applies a change to a copy, leaving the previous state intact", async () => {
|
|
36
36
|
const view = await editor();
|
|
37
37
|
const before = view.result.current.document;
|
|
@@ -76,7 +76,7 @@ describe("useDashboardEditor: editing", () => {
|
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
describe("
|
|
79
|
+
describe("useReportEditor: history", () => {
|
|
80
80
|
it("undoes and redoes a change", async () => {
|
|
81
81
|
const view = await editor();
|
|
82
82
|
act(() => {
|
|
@@ -140,7 +140,7 @@ describe("useDashboardEditor: history", () => {
|
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
describe("
|
|
143
|
+
describe("useReportEditor: saving", () => {
|
|
144
144
|
it("splices the change into the file and keeps its comments", async () => {
|
|
145
145
|
let written: string | undefined;
|
|
146
146
|
const view = await editor((source) => {
|
|
@@ -262,7 +262,7 @@ describe("useDashboardEditor: saving", () => {
|
|
|
262
262
|
* `structural` is what a save reports as structural, so it has to mean what the WRITER means by a changed tile — not what
|
|
263
263
|
* the grid means.
|
|
264
264
|
*/
|
|
265
|
-
describe("
|
|
265
|
+
describe("useReportEditor: structural", () => {
|
|
266
266
|
it("is false for presentation and layout edits", async () => {
|
|
267
267
|
const view = await editor();
|
|
268
268
|
act(() => {
|
package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts}
RENAMED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useDocumentEditor,
|
|
12
12
|
} from "./useDocumentEditor";
|
|
13
13
|
|
|
14
|
-
export type
|
|
14
|
+
export type ReportEditorHandle = DocumentEditor<DashboardDocument>;
|
|
15
15
|
export type { SaveOutcome };
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -31,7 +31,7 @@ const tilesChanged = (saved: DashboardDocument, next: DashboardDocument) => {
|
|
|
31
31
|
);
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
export function
|
|
34
|
+
export function useReportEditor(options: {
|
|
35
35
|
/** The file as read from storage. */
|
|
36
36
|
source: string;
|
|
37
37
|
/** The document that file produced. */
|
|
@@ -46,31 +46,20 @@ export function useDashboardEditor(options: {
|
|
|
46
46
|
conversion?: { from: string; to: string };
|
|
47
47
|
/** The file a save overwrites when `source` is a draft of it ({@link DocumentEditorOptions.replaces}). */
|
|
48
48
|
replaces?: string;
|
|
49
|
-
/** The file's path within the package. */
|
|
50
|
-
modelPath?: string;
|
|
51
|
-
/** The document is held as text: a kind switch always writes `kind=`. */
|
|
52
|
-
explicitKind?: boolean;
|
|
53
49
|
/** The sources a document held as text sees without an `import`. */
|
|
54
50
|
visibleSources?: readonly string[];
|
|
55
|
-
}):
|
|
56
|
-
const { conversion,
|
|
57
|
-
options;
|
|
51
|
+
}): ReportEditorHandle {
|
|
52
|
+
const { conversion, visibleSources, ...rest } = options;
|
|
58
53
|
const from = conversion?.from;
|
|
59
54
|
const to = conversion?.to;
|
|
60
55
|
const splice = useCallback(
|
|
61
56
|
(text: string, document: DashboardDocument) =>
|
|
62
|
-
// The kind is only ever changed by the settings toggle, so the writer is always allowed to follow it.
|
|
63
57
|
spliceDashboardDocument(
|
|
64
58
|
from !== undefined && text === from ? (to as string) : text,
|
|
65
59
|
document,
|
|
66
|
-
{
|
|
67
|
-
changeKind: true,
|
|
68
|
-
...(modelPath !== undefined ? { modelPath } : {}),
|
|
69
|
-
...(explicitKind ? { explicitKind } : {}),
|
|
70
|
-
...(visibleSources ? { visibleSources } : {}),
|
|
71
|
-
},
|
|
60
|
+
visibleSources ? { visibleSources } : {},
|
|
72
61
|
),
|
|
73
|
-
[from, to,
|
|
62
|
+
[from, to, visibleSources],
|
|
74
63
|
);
|
|
75
64
|
return useDocumentEditor({
|
|
76
65
|
...rest,
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
type SetStateAction,
|
|
11
11
|
} from "react";
|
|
12
12
|
import { modelResultsKey } from "../../hooks/useQueryResult";
|
|
13
|
-
import { encodeResourceUri } from "../../utils/formatting";
|
|
14
13
|
import {
|
|
15
14
|
isDocumentNotFound,
|
|
16
15
|
type DocumentStorage,
|
|
@@ -18,7 +17,8 @@ import {
|
|
|
18
17
|
} from "../DocumentStorage";
|
|
19
18
|
import { locatorFor } from "../DocumentCreate/documentPath";
|
|
20
19
|
import type { useServer } from "../ServerProvider";
|
|
21
|
-
import type {
|
|
20
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
21
|
+
import { invalidateReportQueries } from "../Package/reportQueries";
|
|
22
22
|
import {
|
|
23
23
|
expectedHashFor,
|
|
24
24
|
saveTarget,
|
|
@@ -35,7 +35,7 @@ import type { OpenedDocument } from "./useOpenedDocument";
|
|
|
35
35
|
export function useSaveChannel({
|
|
36
36
|
storage,
|
|
37
37
|
workspace,
|
|
38
|
-
|
|
38
|
+
layout,
|
|
39
39
|
notebook,
|
|
40
40
|
environmentName,
|
|
41
41
|
packageName,
|
|
@@ -60,7 +60,9 @@ export function useSaveChannel({
|
|
|
60
60
|
}: {
|
|
61
61
|
storage: DocumentStorage | undefined;
|
|
62
62
|
workspace: Workspace | undefined;
|
|
63
|
-
|
|
63
|
+
/** The layout the report opened with: what a save records until the document says otherwise. */
|
|
64
|
+
layout: ReportLayout;
|
|
65
|
+
/** The report opened linear: its record is read back only from an authoritative store. */
|
|
64
66
|
notebook: boolean;
|
|
65
67
|
environmentName: string;
|
|
66
68
|
packageName: string;
|
|
@@ -87,25 +89,31 @@ export function useSaveChannel({
|
|
|
87
89
|
packageBaseRef: MutableRefObject<string | undefined>;
|
|
88
90
|
fetchedAtRef: MutableRefObject<number>;
|
|
89
91
|
}) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
// The document's address in the host's store; a save records the layout the document has then.
|
|
93
|
+
const locatorAt = useCallback(
|
|
94
|
+
(at: ReportLayout) =>
|
|
95
|
+
workspace === undefined
|
|
96
|
+
? undefined
|
|
97
|
+
: locatorFor(
|
|
98
|
+
at,
|
|
99
|
+
workspace.name,
|
|
100
|
+
environmentName,
|
|
101
|
+
packageName,
|
|
102
|
+
modelPath,
|
|
103
|
+
),
|
|
104
|
+
[workspace, environmentName, packageName, modelPath],
|
|
105
|
+
);
|
|
106
|
+
const locator = locatorAt(layout);
|
|
100
107
|
// Into the host's store: the record when the host says so, and otherwise a
|
|
101
108
|
// copy kept beside the package.
|
|
102
109
|
const saveToStorage = useCallback(
|
|
103
|
-
async (source: string) => {
|
|
104
|
-
|
|
110
|
+
async (source: string, saved: ReportLayout = layout) => {
|
|
111
|
+
const at = locatorAt(saved);
|
|
112
|
+
if (!storage || !at)
|
|
105
113
|
throw new Error(
|
|
106
114
|
"This host keeps no documents, so there is nowhere to save.",
|
|
107
115
|
);
|
|
108
|
-
await storage.saveDocument(
|
|
116
|
+
await storage.saveDocument(at, source);
|
|
109
117
|
// The builder keeps its history and its text; what it holds is now
|
|
110
118
|
// this, not the text it was opened with.
|
|
111
119
|
setOpened((previous) => previous && { ...previous, source });
|
|
@@ -120,7 +128,8 @@ export function useSaveChannel({
|
|
|
120
128
|
},
|
|
121
129
|
[
|
|
122
130
|
storage,
|
|
123
|
-
|
|
131
|
+
locatorAt,
|
|
132
|
+
layout,
|
|
124
133
|
authoritative,
|
|
125
134
|
resume,
|
|
126
135
|
setOpened,
|
|
@@ -202,24 +211,14 @@ export function useSaveChannel({
|
|
|
202
211
|
}),
|
|
203
212
|
},
|
|
204
213
|
{ queryKey: ["dashboard-editor-manifest"] },
|
|
205
|
-
{ queryKey: ["dashboards"] },
|
|
206
|
-
{ queryKey: ["dashboard"] },
|
|
207
|
-
// The notebook viewer keys its read on the resource URI.
|
|
208
|
-
...(notebook
|
|
209
|
-
? [
|
|
210
|
-
{
|
|
211
|
-
queryKey: [
|
|
212
|
-
encodeResourceUri({
|
|
213
|
-
environmentName,
|
|
214
|
-
packageName,
|
|
215
|
-
modelPath,
|
|
216
|
-
}),
|
|
217
|
-
],
|
|
218
|
-
},
|
|
219
|
-
]
|
|
220
|
-
: []),
|
|
221
214
|
],
|
|
222
215
|
});
|
|
216
|
+
invalidateReportQueries(
|
|
217
|
+
queryClient,
|
|
218
|
+
environmentName,
|
|
219
|
+
packageName,
|
|
220
|
+
modelPath,
|
|
221
|
+
);
|
|
223
222
|
},
|
|
224
223
|
[
|
|
225
224
|
apiClients,
|
|
@@ -257,7 +256,9 @@ export function useSaveChannel({
|
|
|
257
256
|
(!notebook || authoritative),
|
|
258
257
|
readFailed: readFailure !== undefined,
|
|
259
258
|
});
|
|
260
|
-
const save
|
|
259
|
+
const save:
|
|
260
|
+
| ((source: string, layout?: ReportLayout) => Promise<void>)
|
|
261
|
+
| undefined =
|
|
261
262
|
writer === "storage"
|
|
262
263
|
? saveToStorage
|
|
263
264
|
: writer === "package"
|
|
@@ -5,7 +5,7 @@ import { useState } from "react";
|
|
|
5
5
|
import type { NewTile } from "./AddTileDialog";
|
|
6
6
|
import { isTextTile, tileKey, type DashboardTile } from "./document";
|
|
7
7
|
import { addTileToDocument } from "./addTileToDocument";
|
|
8
|
-
import type {
|
|
8
|
+
import type { ReportEditorHandle } from "./useReportEditor";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Adding, changing and removing tiles, with the add-tile picker and a tile's
|
|
@@ -20,7 +20,7 @@ export function useTileEditing({
|
|
|
20
20
|
selectTile,
|
|
21
21
|
deselectTile,
|
|
22
22
|
}: {
|
|
23
|
-
editor:
|
|
23
|
+
editor: ReportEditorHandle;
|
|
24
24
|
notebook: boolean;
|
|
25
25
|
columns: number;
|
|
26
26
|
/** The document's file within the package, which a tile's import is relative to. */
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
NotebooksApi,
|
|
24
24
|
PackagesApi,
|
|
25
25
|
PublisherApi,
|
|
26
|
+
ReportsApi,
|
|
26
27
|
WatchModeApi,
|
|
27
28
|
} from "../client";
|
|
28
29
|
import { Configuration } from "../client/configuration";
|
|
@@ -146,6 +147,7 @@ const getApiClients = (
|
|
|
146
147
|
dashboards: new DashboardsApi(config, basePath, axiosInstance),
|
|
147
148
|
dataApps: new DataAppsApi(config, basePath, axiosInstance),
|
|
148
149
|
notebooks: new NotebooksApi(config, basePath, axiosInstance),
|
|
150
|
+
reports: new ReportsApi(config, basePath, axiosInstance),
|
|
149
151
|
connections: new ConnectionsApi(config, basePath, axiosInstance),
|
|
150
152
|
databases: new DatabasesApi(config, basePath, axiosInstance),
|
|
151
153
|
materializations: new MaterializationsApi(
|
|
@@ -116,7 +116,7 @@ export function drillDestinations(field: DrillField | undefined): string[] {
|
|
|
116
116
|
if (!drill) return [];
|
|
117
117
|
// Malloyyo accepts a lone destination unbracketed (`to=overview`) as well as
|
|
118
118
|
// the list form. The server grows the same leniency in `readDrillTag`
|
|
119
|
-
// (`service/
|
|
119
|
+
// (`service/report_manifest.ts`) with the dashboard slice of this split; it is not
|
|
120
120
|
// in the tree yet, so keep the two in step when it lands.
|
|
121
121
|
return (
|
|
122
122
|
drill.textArray("to") ?? [drill.text("to")].filter(isNonEmpty)
|
|
@@ -158,7 +158,14 @@ export function drillGivenName(field: DrillField): string {
|
|
|
158
158
|
|
|
159
159
|
/** Where a `# drill` click wants to go, for the host to route however it routes. */
|
|
160
160
|
export interface DrillNavigation {
|
|
161
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* The destination report, as the tag's `to=` names it: a package path
|
|
163
|
+
* without `.malloy` (`sales/overview`); a bare name is a file at the root.
|
|
164
|
+
* It may contain `/`, so resolve it with `resolveDrillTarget` against
|
|
165
|
+
* `GET …/reports` rather than using it as one URL segment.
|
|
166
|
+
*/
|
|
167
|
+
path: string;
|
|
168
|
+
/** @deprecated Use `path`; always the same value. */
|
|
162
169
|
dashboard: string;
|
|
163
170
|
/**
|
|
164
171
|
* Control values to open it with: the clicked value seeded into the drill's
|