@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
|
@@ -2,28 +2,27 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import "@malloydata/malloy-explorer/styles.css";
|
|
5
|
-
import {
|
|
5
|
+
import { Stack, Typography } from "@mui/material";
|
|
6
6
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { GivenValue } from "../../hooks/givenValue";
|
|
7
|
+
import type { NotebookCell as RawCell, RawNotebook } from "../../client";
|
|
8
|
+
import type { GivenValue } from "../../hooks/givenValue";
|
|
10
9
|
import { useDocumentControls } from "../../hooks/useDocumentControls";
|
|
11
10
|
import { useModelGivens } from "../../hooks/useModelGivens";
|
|
12
11
|
import { GIVEN_SETTLE_MS } from "../../hooks/useSettled";
|
|
13
|
-
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
14
12
|
import { parseResourceUri } from "../../utils/formatting";
|
|
15
|
-
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
13
|
+
import { ApiErrorDisplay, type ApiError } from "../ApiErrorDisplay";
|
|
16
14
|
import type { NavigationClick } from "../click_helper";
|
|
17
|
-
import { DashboardProse, DashboardView } from "../Dashboard/DashboardView";
|
|
18
15
|
import type { DrillNavigation } from "../drill";
|
|
19
16
|
import { GivensPanel } from "../given";
|
|
20
17
|
import { givensToParams, givensToRequest } from "../given/paramCodec";
|
|
21
18
|
import { Loading, LOADING_COPY } from "../Loading";
|
|
19
|
+
import { cellRuns } from "../Notebook/cellKind";
|
|
20
|
+
import { NotebookCell } from "../Notebook/NotebookCell";
|
|
21
|
+
import { planRun } from "../Notebook/runPlan";
|
|
22
|
+
import type { EnhancedNotebookCell } from "../Notebook/types";
|
|
22
23
|
import { useServer } from "../ServerProvider";
|
|
24
|
+
import { failureCategory, useReportEvents } from "./telemetry";
|
|
23
25
|
import { CleanNotebookContainer, CleanNotebookSection } from "../styles";
|
|
24
|
-
import { cellRuns } from "./cellKind";
|
|
25
|
-
import { NotebookCell } from "./NotebookCell";
|
|
26
|
-
import { EnhancedNotebookCell } from "./types";
|
|
27
26
|
|
|
28
27
|
// Maximum number of concurrent cell executions to avoid overwhelming the server
|
|
29
28
|
const MAX_CONCURRENT = 4;
|
|
@@ -45,13 +44,28 @@ function cellErrorMessage(error: unknown): string {
|
|
|
45
44
|
return "The server did not say why.";
|
|
46
45
|
}
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
/** What one cell's run is handed: the cell, its index, the values to run it with, and the signal that cancels it. */
|
|
48
|
+
interface CellRun {
|
|
49
|
+
cell: RawCell;
|
|
50
|
+
index: number;
|
|
51
|
+
givens: ReadonlyMap<string, GivenValue>;
|
|
52
|
+
declaredTypes: ReadonlyMap<string, string | undefined>;
|
|
53
|
+
signal: AbortSignal;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Runs one cell. Stable across renders: a new runner re-runs every cell. */
|
|
57
|
+
export type CellRunner = (
|
|
58
|
+
run: CellRun,
|
|
59
|
+
) => Promise<{ result?: string; newSources?: string[] }>;
|
|
60
|
+
|
|
61
|
+
export interface CellReportProps {
|
|
62
|
+
/** `publisher://…/models/<path>`: the report, and the model its cells run against. */
|
|
49
63
|
resourceUri: string;
|
|
50
64
|
maxResultSize?: number;
|
|
51
65
|
/**
|
|
52
66
|
* Parameter values from the host, typically its URL query parameters: the
|
|
53
|
-
* same contract `
|
|
54
|
-
*
|
|
67
|
+
* same contract `Report` takes, so a link into a filtered report works the
|
|
68
|
+
* way a link into a filtered grid does.
|
|
55
69
|
*/
|
|
56
70
|
givens?: Record<string, string>;
|
|
57
71
|
/**
|
|
@@ -62,130 +76,69 @@ interface NotebookProps {
|
|
|
62
76
|
* That is every committed change. Under `## autorun=false` a change is
|
|
63
77
|
* committed on Apply, so reports are batched; otherwise every change is
|
|
64
78
|
* committed and typing in a text control reports per keystroke. It does NOT
|
|
65
|
-
* run per keystroke: a changed value waits
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
79
|
+
* run per keystroke: a changed value waits `GIVEN_SETTLE_MS` before
|
|
80
|
+
* anything is dispatched, so a burst of typing produces one run. A run that
|
|
81
|
+
* does start supersedes and aborts the one before it. The REPORTS are still
|
|
82
|
+
* per keystroke, so a host doing something expensive per call should
|
|
83
|
+
* debounce.
|
|
70
84
|
*
|
|
71
|
-
* `managed` names every given this
|
|
85
|
+
* `managed` names every given this report declares, set or not. A host
|
|
72
86
|
* writing to a shared query string needs it: `givens` alone says which
|
|
73
|
-
* parameters to write but not which to *remove
|
|
74
|
-
* removing everything it did not just receive deletes the unrelated
|
|
75
|
-
* parameters it has no business touching.
|
|
87
|
+
* parameters to write but not which to *remove*.
|
|
76
88
|
*/
|
|
77
89
|
onGivensChange?: (
|
|
78
90
|
givens: Record<string, string>,
|
|
79
91
|
managed: readonly string[],
|
|
80
92
|
) => void;
|
|
81
93
|
/**
|
|
82
|
-
* Optional SPA navigation handler for links inside the
|
|
83
|
-
*
|
|
84
|
-
*
|
|
94
|
+
* Optional SPA navigation handler for links inside the cells. When omitted,
|
|
95
|
+
* links fall back to plain absolute anchors, so no react-router context is
|
|
96
|
+
* required to render one.
|
|
85
97
|
*
|
|
86
|
-
* It does NOT carry drill. A `# drill { to=self }` filters this
|
|
98
|
+
* It does NOT carry drill. A `# drill { to=self }` filters this report
|
|
87
99
|
* through `given:` state and needs no handler at all, and a drill naming a
|
|
88
|
-
*
|
|
100
|
+
* report goes through {@link onDrillNavigate}, which takes a destination
|
|
89
101
|
* rather than a URL.
|
|
90
102
|
*/
|
|
91
103
|
onNavigate?: (to: string, event?: NavigationClick) => void;
|
|
92
104
|
/**
|
|
93
|
-
* Opens a `# drill { to=<
|
|
94
|
-
* value. Omitted on a host with no
|
|
105
|
+
* Opens a `# drill { to=<report> }` from a cell, seeded with the clicked
|
|
106
|
+
* value. Omitted on a host with no report route, which leaves those
|
|
95
107
|
* destinations inert AND unmarked rather than painting a dead link.
|
|
96
108
|
*/
|
|
97
109
|
onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
98
110
|
}
|
|
99
111
|
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
modelPath: notebookPath,
|
|
108
|
-
} = parseResourceUri(resourceUri);
|
|
109
|
-
return useQueryWithApiError<RawNotebook>({
|
|
110
|
-
queryKey: [resourceUri],
|
|
111
|
-
queryFn: async () => {
|
|
112
|
-
const response = await apiClients.notebooks.getNotebook(
|
|
113
|
-
environmentName,
|
|
114
|
-
packageName,
|
|
115
|
-
notebookPath,
|
|
116
|
-
versionId,
|
|
117
|
-
);
|
|
118
|
-
return response.data;
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Requires PackageProvider
|
|
124
|
-
export default function Notebook(props: NotebookProps) {
|
|
125
|
-
const { data: notebook } = useNotebookQuery(props.resourceUri);
|
|
126
|
-
// A notebook written as a tile layout renders as a one-column dashboard.
|
|
127
|
-
if (notebook?.dashboard) {
|
|
128
|
-
const { environmentName, packageName, versionId, modelPath } =
|
|
129
|
-
parseResourceUri(props.resourceUri);
|
|
130
|
-
const { title, description } = notebook.dashboard;
|
|
131
|
-
return (
|
|
132
|
-
<CleanNotebookContainer>
|
|
133
|
-
<CleanNotebookSection>
|
|
134
|
-
{/* chrome="none" drops the view's own header, so the prose is drawn here. */}
|
|
135
|
-
{(title || description) && (
|
|
136
|
-
<Box sx={{ mb: 2 }}>
|
|
137
|
-
<DashboardProse
|
|
138
|
-
// A notebook's text tiles have no card; its description matches them.
|
|
139
|
-
chrome="none"
|
|
140
|
-
title={title ?? ""}
|
|
141
|
-
{...(description ? { description } : {})}
|
|
142
|
-
/>
|
|
143
|
-
</Box>
|
|
144
|
-
)}
|
|
145
|
-
<DashboardView
|
|
146
|
-
manifest={notebook.dashboard}
|
|
147
|
-
environmentName={environmentName}
|
|
148
|
-
packageName={packageName}
|
|
149
|
-
versionId={versionId}
|
|
150
|
-
documentName={modelPath}
|
|
151
|
-
givens={props.givens}
|
|
152
|
-
onGivensChange={props.onGivensChange}
|
|
153
|
-
onNavigate={props.onDrillNavigate}
|
|
154
|
-
maxResultSize={props.maxResultSize}
|
|
155
|
-
chrome="none"
|
|
156
|
-
// A cell notebook's control panel, not a dashboard's bar.
|
|
157
|
-
controlsLayout="panel"
|
|
158
|
-
/>
|
|
159
|
-
</CleanNotebookSection>
|
|
160
|
-
</CleanNotebookContainer>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
return <CellNotebook {...props} />;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function CellNotebook({
|
|
112
|
+
/**
|
|
113
|
+
* Cells run one by one, the engine behind a report written as `run:` cells.
|
|
114
|
+
* Takes the cells (undefined while they load, `error` when they could not be
|
|
115
|
+
* read) and the runner that executes one; what reads the cells and what runs
|
|
116
|
+
* them is the caller's.
|
|
117
|
+
*/
|
|
118
|
+
export function CellRunnerView({
|
|
167
119
|
resourceUri,
|
|
168
120
|
maxResultSize = 0,
|
|
169
121
|
givens,
|
|
170
122
|
onGivensChange,
|
|
171
123
|
onNavigate,
|
|
172
124
|
onDrillNavigate,
|
|
173
|
-
|
|
174
|
-
|
|
125
|
+
notebook,
|
|
126
|
+
error,
|
|
127
|
+
runCell,
|
|
128
|
+
}: CellReportProps & {
|
|
129
|
+
notebook: RawNotebook | undefined;
|
|
130
|
+
/** Why the cells could not be read; the view says so in place of them. */
|
|
131
|
+
error?: ApiError | null;
|
|
132
|
+
runCell: CellRunner;
|
|
133
|
+
}) {
|
|
175
134
|
const {
|
|
176
135
|
environmentName,
|
|
177
136
|
packageName,
|
|
178
137
|
versionId,
|
|
179
138
|
modelPath: notebookPath,
|
|
180
139
|
} = parseResourceUri(resourceUri);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const {
|
|
184
|
-
data: notebook,
|
|
185
|
-
isSuccess,
|
|
186
|
-
isError,
|
|
187
|
-
error,
|
|
188
|
-
} = useNotebookQuery(resourceUri);
|
|
140
|
+
const isSuccess = notebook !== undefined;
|
|
141
|
+
const isError = !isSuccess && !!error;
|
|
189
142
|
|
|
190
143
|
// State to store executed cells with results
|
|
191
144
|
const [enhancedCells, setEnhancedCells] = useState<EnhancedNotebookCell[]>(
|
|
@@ -196,19 +149,21 @@ function CellNotebook({
|
|
|
196
149
|
// `isExecuting`, which covers only a run actually in flight.
|
|
197
150
|
const [runScheduled, setRunScheduled] = useState(false);
|
|
198
151
|
// The document the last run belonged to, for abandoning its requests when
|
|
199
|
-
// the reader moves to another
|
|
152
|
+
// the reader moves to another report without this component unmounting.
|
|
200
153
|
const lastDocumentRef = useRef<string | undefined>(undefined);
|
|
201
154
|
const [executionError, setExecutionError] = useState<Error | null>(null);
|
|
202
155
|
|
|
203
156
|
// Model-level `given:` declarations, and the state behind their controls:
|
|
204
|
-
// the same hook
|
|
157
|
+
// the same hook a grid uses, so both layouts get URL-addressable
|
|
205
158
|
// parameters, Apply batching and `to=self` drill from one implementation.
|
|
206
159
|
const declaredGivens = useModelGivens(notebook);
|
|
207
160
|
// A file-level `## autorun=false` arrives as `RawNotebook.autorun`, the same
|
|
208
|
-
// field with the same default a
|
|
209
|
-
// produces. Batching matters more here than on a
|
|
210
|
-
//
|
|
161
|
+
// field with the same default a grid's `## artifact { autorun=false }`
|
|
162
|
+
// produces. Batching matters more here than on a grid: one control change
|
|
163
|
+
// re-runs every cell in the document.
|
|
211
164
|
const autorun = notebook?.autorun !== false;
|
|
165
|
+
// Set by `Report`; silent under the deprecated `Notebook`, which shares this view.
|
|
166
|
+
const events = useReportEvents();
|
|
212
167
|
const controls = useDocumentControls({
|
|
213
168
|
specs: declaredGivens,
|
|
214
169
|
loaded: isSuccess,
|
|
@@ -220,7 +175,7 @@ function CellNotebook({
|
|
|
220
175
|
autorun,
|
|
221
176
|
environmentName,
|
|
222
177
|
packageName,
|
|
223
|
-
//
|
|
178
|
+
// The report's model path is the report itself: `suggest` queries run
|
|
224
179
|
// against the same model the cells do.
|
|
225
180
|
modelPath: notebookPath,
|
|
226
181
|
versionId,
|
|
@@ -233,13 +188,8 @@ function CellNotebook({
|
|
|
233
188
|
onSelf: onDrillSelf,
|
|
234
189
|
} = controls;
|
|
235
190
|
|
|
236
|
-
/**
|
|
237
|
-
|
|
238
|
-
* dashboard's POST body carries, JSON-encoded because this endpoint takes it
|
|
239
|
-
* in the URL. Built by the shared codec so a given is encoded identically
|
|
240
|
-
* whichever surface runs it.
|
|
241
|
-
*/
|
|
242
|
-
const buildGivens = useCallback(
|
|
191
|
+
/** The run key's encoding of a set of values: the request body the cells are sent, so values that encode identically do not re-run. */
|
|
192
|
+
const encodeGivens = useCallback(
|
|
243
193
|
(values: Map<string, GivenValue>): string | undefined => {
|
|
244
194
|
const request = givensToRequest(values, declaredTypes);
|
|
245
195
|
return Object.keys(request).length > 0
|
|
@@ -249,7 +199,7 @@ function CellNotebook({
|
|
|
249
199
|
[declaredTypes],
|
|
250
200
|
);
|
|
251
201
|
|
|
252
|
-
// For a cell's "Data Sources" dialog: the
|
|
202
|
+
// For a cell's "Data Sources" dialog: the report's current values, so
|
|
253
203
|
// exploring from a cell starts from what the reader is looking at rather
|
|
254
204
|
// than the model's bare defaults.
|
|
255
205
|
const cellStartingGivens = useMemo(
|
|
@@ -276,32 +226,22 @@ function CellNotebook({
|
|
|
276
226
|
>(undefined);
|
|
277
227
|
|
|
278
228
|
// Cancel whatever is in flight when this component goes away, so navigating
|
|
279
|
-
// off a twelve-cell
|
|
229
|
+
// off a twelve-cell report does not leave twelve requests to complete and be
|
|
280
230
|
// thrown away.
|
|
281
231
|
//
|
|
282
|
-
// Its OWN effect, with an empty dependency list,
|
|
283
|
-
//
|
|
284
|
-
//
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
// saw an unchanged key and refused to start a replacement. Every cell was left
|
|
288
|
-
// blank, with no result, no error and no spinner, until a reload. Measured on
|
|
289
|
-
// `governed-analytics/orders.malloynb`: 4 rendered results before a control
|
|
290
|
-
// change, 0 after.
|
|
232
|
+
// Its OWN effect, with an empty dependency list, not the run effect's
|
|
233
|
+
// cleanup: the host echoes each reported parameter back, giving `applied` a
|
|
234
|
+
// new identity with identical content. A cleanup on that change would abort
|
|
235
|
+
// the run the control change just started, while the `runKey` guard sees an
|
|
236
|
+
// unchanged key and starts no replacement, leaving every cell blank.
|
|
291
237
|
useEffect(
|
|
292
238
|
() => () => {
|
|
293
239
|
inFlightRef.current?.abort();
|
|
294
240
|
// Forget which run was last started, so a component that comes back
|
|
295
|
-
// runs again instead of trusting a key whose run was just cancelled
|
|
296
|
-
//
|
|
297
|
-
//
|
|
298
|
-
//
|
|
299
|
-
// cached would start a run, this cleanup would abort it, and the
|
|
300
|
-
// second mount would see an unchanged `runKey` and decline to start a
|
|
301
|
-
// replacement. I could not get a browser into that state, so treat the
|
|
302
|
-
// reset as belt-and-braces rather than a measured fix. It is right on
|
|
303
|
-
// its own terms either way: a key that says "this run happened" must
|
|
304
|
-
// not outlive the run being cancelled.
|
|
241
|
+
// runs again instead of trusting a key whose run was just cancelled
|
|
242
|
+
// (React's StrictMode mounts, cleans up, and mounts again, and refs
|
|
243
|
+
// survive that). A key that says "this run happened" must not outlive
|
|
244
|
+
// the run being cancelled.
|
|
305
245
|
lastRunRef.current = null;
|
|
306
246
|
clearTimeout(pendingRunRef.current?.timer);
|
|
307
247
|
pendingRunRef.current = undefined;
|
|
@@ -315,33 +255,22 @@ function CellNotebook({
|
|
|
315
255
|
const runId = ++runIdRef.current;
|
|
316
256
|
|
|
317
257
|
// Cancel the run this one supersedes rather than just ignoring its
|
|
318
|
-
// results
|
|
319
|
-
// three quick control changes on a twelve-cell
|
|
320
|
-
// runs on the server and use the answers from one.
|
|
321
|
-
// refused to start a second run at all, which was the wrong trade,
|
|
322
|
-
// it dropped the newest values, but it did bound the load, and
|
|
323
|
-
// nothing replaced that bound.
|
|
258
|
+
// results: discarding results alone keeps the requests in flight, so
|
|
259
|
+
// three quick control changes on a twelve-cell report put three full
|
|
260
|
+
// runs on the server and use the answers from one.
|
|
324
261
|
inFlightRef.current?.abort();
|
|
325
262
|
const controller = new AbortController();
|
|
326
263
|
inFlightRef.current = controller;
|
|
327
264
|
|
|
328
|
-
// Rebuilt from the
|
|
329
|
-
// previous render's cells
|
|
330
|
-
//
|
|
331
|
-
// on top, so navigating between two notebooks rendered one's prose
|
|
332
|
-
// with the other's charts, and a shorter second notebook left the
|
|
333
|
-
// first one's trailing cells on screen. Nothing worth preserving
|
|
334
|
-
// survived that branch anyway: `result` and `error` were cleared, and
|
|
335
|
-
// `newSources` is re-derived from the raw cell below.
|
|
265
|
+
// Rebuilt from the report being run, never carried over from the
|
|
266
|
+
// previous render's cells, which would keep the OLD document's text
|
|
267
|
+
// under the new document's results.
|
|
336
268
|
setEnhancedCells(notebook.notebookCells.map((cell) => ({ ...cell })));
|
|
337
269
|
|
|
338
270
|
setIsExecuting(true);
|
|
339
271
|
setExecutionError(null);
|
|
340
272
|
|
|
341
|
-
const givensParam = buildGivens(givensToApply);
|
|
342
|
-
|
|
343
273
|
try {
|
|
344
|
-
// Build execution tasks for code cells
|
|
345
274
|
const executionTasks: Array<() => Promise<void>> = [];
|
|
346
275
|
|
|
347
276
|
for (let i = 0; i < notebook.notebookCells.length; i++) {
|
|
@@ -350,38 +279,26 @@ function CellNotebook({
|
|
|
350
279
|
// Prose and definitions have nothing to run.
|
|
351
280
|
if (!cellRuns(rawCell)) continue;
|
|
352
281
|
|
|
353
|
-
// Capture cell index for closure
|
|
354
282
|
const cellIndex = i;
|
|
355
283
|
|
|
356
284
|
const executeCell = async () => {
|
|
357
285
|
try {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
await apiClients.notebooks.executeNotebookCell(
|
|
366
|
-
environmentName,
|
|
367
|
-
packageName,
|
|
368
|
-
notebookPath,
|
|
369
|
-
cellIndex,
|
|
370
|
-
versionId,
|
|
371
|
-
undefined,
|
|
372
|
-
undefined,
|
|
373
|
-
givensParam,
|
|
374
|
-
{ signal: controller.signal },
|
|
375
|
-
);
|
|
286
|
+
const executedCell = await runCell({
|
|
287
|
+
cell: rawCell,
|
|
288
|
+
index: cellIndex,
|
|
289
|
+
givens: givensToApply,
|
|
290
|
+
declaredTypes,
|
|
291
|
+
signal: controller.signal,
|
|
292
|
+
});
|
|
376
293
|
|
|
377
294
|
if (runIdRef.current !== runId) return;
|
|
378
295
|
|
|
379
|
-
const executedCell = response.data;
|
|
380
296
|
const result = executedCell.result;
|
|
297
|
+
// A `.malloy` report's cells carry their sources on the
|
|
298
|
+
// manifest; a run adds none.
|
|
381
299
|
const newSources =
|
|
382
300
|
rawCell.newSources || executedCell.newSources;
|
|
383
301
|
|
|
384
|
-
// Update state incrementally
|
|
385
302
|
setEnhancedCells((prev) => {
|
|
386
303
|
const next = [...prev];
|
|
387
304
|
if (!next[cellIndex]) {
|
|
@@ -402,10 +319,18 @@ function CellNotebook({
|
|
|
402
319
|
runIdRef.current !== runId
|
|
403
320
|
)
|
|
404
321
|
return;
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
322
|
+
// The cell shows its error; the host hears of it, or
|
|
323
|
+
// without one the console does, so it is never lost.
|
|
324
|
+
events.emit({
|
|
325
|
+
type: "report.query_failed",
|
|
326
|
+
tile: cellIndex,
|
|
327
|
+
category: failureCategory(cellError),
|
|
328
|
+
});
|
|
329
|
+
if (!events.listening)
|
|
330
|
+
console.error(
|
|
331
|
+
`Error executing cell ${cellIndex}:`,
|
|
332
|
+
cellError,
|
|
333
|
+
);
|
|
409
334
|
const message = cellErrorMessage(cellError);
|
|
410
335
|
setEnhancedCells((prev) => {
|
|
411
336
|
const next = [...prev];
|
|
@@ -438,11 +363,15 @@ function CellNotebook({
|
|
|
438
363
|
}
|
|
439
364
|
}
|
|
440
365
|
|
|
441
|
-
// Wait for remaining tasks to complete
|
|
442
366
|
await Promise.all(executing);
|
|
443
367
|
} catch (error) {
|
|
444
368
|
if (controller.signal.aborted || runIdRef.current !== runId) return;
|
|
445
|
-
|
|
369
|
+
events.emit({
|
|
370
|
+
type: "report.query_failed",
|
|
371
|
+
category: failureCategory(error),
|
|
372
|
+
});
|
|
373
|
+
if (!events.listening)
|
|
374
|
+
console.error("Error executing notebook cells:", error);
|
|
446
375
|
setExecutionError(error as Error);
|
|
447
376
|
} finally {
|
|
448
377
|
if (runIdRef.current === runId) {
|
|
@@ -451,34 +380,22 @@ function CellNotebook({
|
|
|
451
380
|
}
|
|
452
381
|
}
|
|
453
382
|
},
|
|
454
|
-
[
|
|
455
|
-
isSuccess,
|
|
456
|
-
notebook,
|
|
457
|
-
buildGivens,
|
|
458
|
-
environmentName,
|
|
459
|
-
packageName,
|
|
460
|
-
notebookPath,
|
|
461
|
-
versionId,
|
|
462
|
-
apiClients.notebooks,
|
|
463
|
-
],
|
|
383
|
+
[isSuccess, notebook, declaredTypes, runCell, events],
|
|
464
384
|
);
|
|
465
385
|
|
|
466
386
|
// Run the cells on load, and again whenever the applied parameters change.
|
|
467
387
|
// Applied, not draft: under `## autorun=false` the cells wait for Apply.
|
|
468
388
|
//
|
|
469
389
|
// One effect covers both, keyed on exactly what would go over the wire plus
|
|
470
|
-
// which
|
|
390
|
+
// which report it is. Keying on the encoded givens means a change that
|
|
471
391
|
// encodes identically does not re-run, and a link carrying parameters runs
|
|
472
392
|
// once with them rather than running bare and running again when they land.
|
|
473
393
|
// A run already in flight is superseded rather than waited on, which the
|
|
474
394
|
// generation guard in `executeCells` makes safe.
|
|
475
395
|
//
|
|
476
|
-
// The
|
|
477
|
-
//
|
|
478
|
-
//
|
|
479
|
-
// "has this document changed" signal. Keying on `resourceUri` alone silently
|
|
480
|
-
// dropped that: a reloaded notebook kept rendering the previous run's
|
|
481
|
-
// results forever, because the URI and the givens were unchanged.
|
|
396
|
+
// The cells' own identity is part of that key: a package reload hands over
|
|
397
|
+
// a new object only when the content actually differs, so identity is
|
|
398
|
+
// exactly the "has this document changed" signal.
|
|
482
399
|
const notebookGenRef = useRef(0);
|
|
483
400
|
const seenNotebookRef = useRef<RawNotebook | undefined>(undefined);
|
|
484
401
|
if (seenNotebookRef.current !== notebook) {
|
|
@@ -489,13 +406,11 @@ function CellNotebook({
|
|
|
489
406
|
|
|
490
407
|
useEffect(() => {
|
|
491
408
|
const documentKey = `${resourceUri}|${notebookGen}`;
|
|
492
|
-
const runKey = `${documentKey}|${
|
|
409
|
+
const runKey = `${documentKey}|${encodeGivens(applied) ?? ""}`;
|
|
493
410
|
|
|
494
|
-
// Abandon the previous
|
|
411
|
+
// Abandon the previous report's requests when the document changes.
|
|
495
412
|
// The abort-on-unmount effect does not cover this: navigating from one
|
|
496
|
-
//
|
|
497
|
-
// twelve-cell notebook left twelve requests running against a document
|
|
498
|
-
// the reader had already left.
|
|
413
|
+
// report to another REUSES this component, so nothing unmounts.
|
|
499
414
|
if (
|
|
500
415
|
lastDocumentRef.current !== undefined &&
|
|
501
416
|
lastDocumentRef.current !== documentKey
|
|
@@ -531,11 +446,8 @@ function CellNotebook({
|
|
|
531
446
|
start();
|
|
532
447
|
return;
|
|
533
448
|
}
|
|
534
|
-
// Flagged while the settle timer runs, so the cells say a run is coming
|
|
535
|
-
//
|
|
536
|
-
// timer fires, so a changed control sat above the PREVIOUS values with
|
|
537
|
-
// nothing on screen to say they were stale, and a reader who kept typing
|
|
538
|
-
// kept extending the window.
|
|
449
|
+
// Flagged while the settle timer runs, so the cells say a run is coming;
|
|
450
|
+
// `isExecuting` is false until the timer fires.
|
|
539
451
|
setRunScheduled(true);
|
|
540
452
|
pendingRunRef.current = {
|
|
541
453
|
key: runKey,
|
|
@@ -547,13 +459,13 @@ function CellNotebook({
|
|
|
547
459
|
notebookGen,
|
|
548
460
|
resourceUri,
|
|
549
461
|
applied,
|
|
550
|
-
|
|
462
|
+
encodeGivens,
|
|
551
463
|
executeCells,
|
|
552
464
|
]);
|
|
553
465
|
|
|
554
466
|
const shownCells =
|
|
555
467
|
enhancedCells.length > 0 ? enhancedCells : notebook?.notebookCells || [];
|
|
556
|
-
// A served
|
|
468
|
+
// A served report can open with definition cells; a .malloynb keeps the icon on its first cell.
|
|
557
469
|
const copyLinkIndex =
|
|
558
470
|
notebook?.format === "malloy"
|
|
559
471
|
? shownCells.findIndex((cell) => cell.type === "markdown")
|
|
@@ -566,12 +478,10 @@ function CellNotebook({
|
|
|
566
478
|
{/* Parameters panel: the controls for `given:` declarations */}
|
|
567
479
|
<GivensPanel {...controls.panel} />
|
|
568
480
|
|
|
569
|
-
{/* Loading State */}
|
|
570
481
|
{!isSuccess && !isError && (
|
|
571
|
-
<Loading text={LOADING_COPY.opening("
|
|
482
|
+
<Loading text={LOADING_COPY.opening("report")} />
|
|
572
483
|
)}
|
|
573
484
|
|
|
574
|
-
{/* Notebook Cells */}
|
|
575
485
|
{isSuccess &&
|
|
576
486
|
shownCells.map((cell, index) => (
|
|
577
487
|
<NotebookCell
|
|
@@ -597,17 +507,16 @@ function CellNotebook({
|
|
|
597
507
|
/>
|
|
598
508
|
))}
|
|
599
509
|
|
|
600
|
-
{
|
|
601
|
-
{isError && error.status === 404 && (
|
|
510
|
+
{isError && error?.status === 404 && (
|
|
602
511
|
<Typography variant="body2" sx={{ color: "text.secondary" }}>
|
|
603
512
|
<code>{`${environmentName} > ${packageName} > ${notebookPath}`}</code>{" "}
|
|
604
513
|
not found.
|
|
605
514
|
</Typography>
|
|
606
515
|
)}
|
|
607
516
|
|
|
608
|
-
{isError && error
|
|
517
|
+
{isError && error?.status !== 404 && (
|
|
609
518
|
<ApiErrorDisplay
|
|
610
|
-
error={error}
|
|
519
|
+
error={error as ApiError}
|
|
611
520
|
context={`${environmentName} > ${packageName} > ${notebookPath}`}
|
|
612
521
|
/>
|
|
613
522
|
)}
|
|
@@ -627,3 +536,52 @@ function CellNotebook({
|
|
|
627
536
|
</CleanNotebookContainer>
|
|
628
537
|
);
|
|
629
538
|
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* A `.malloy` report written as `run:` cells, whose cells the caller already
|
|
542
|
+
* holds (`Report` reads them off `GET …/reports/{path}`). Each runs through
|
|
543
|
+
* the governed query endpoint the grid tiles use
|
|
544
|
+
* (`POST …/models/{path}/query`, the report's path as the model and the cell's
|
|
545
|
+
* text as the query), which holds a cell to the same surface, `#(authorize)`
|
|
546
|
+
* and row-level gates a tile is held to.
|
|
547
|
+
*/
|
|
548
|
+
export function CellReport({
|
|
549
|
+
notebook: held,
|
|
550
|
+
...props
|
|
551
|
+
}: CellReportProps & { notebook: RawNotebook }) {
|
|
552
|
+
const { apiClients } = useServer();
|
|
553
|
+
const { environmentName, packageName, versionId, modelPath } =
|
|
554
|
+
parseResourceUri(props.resourceUri);
|
|
555
|
+
// Handed over from the first render after mount, not on it, so the
|
|
556
|
+
// controls see the document ARRIVE as they do when it is fetched: that
|
|
557
|
+
// arrival is what reports the file's starting values to the host's URL
|
|
558
|
+
// (`useGivensState` seeds its record from the first render).
|
|
559
|
+
const [mounted, setMounted] = useState(false);
|
|
560
|
+
useEffect(() => setMounted(true), []);
|
|
561
|
+
const runCell = useCallback<CellRunner>(
|
|
562
|
+
async ({ cell, givens, declaredTypes, signal }) => ({
|
|
563
|
+
result: (
|
|
564
|
+
await apiClients.models.executeQueryModel(
|
|
565
|
+
environmentName,
|
|
566
|
+
packageName,
|
|
567
|
+
modelPath,
|
|
568
|
+
{
|
|
569
|
+
query: cell.text,
|
|
570
|
+
givens: givensToRequest(givens, declaredTypes),
|
|
571
|
+
versionId,
|
|
572
|
+
},
|
|
573
|
+
undefined,
|
|
574
|
+
{ signal },
|
|
575
|
+
)
|
|
576
|
+
).data.result,
|
|
577
|
+
}),
|
|
578
|
+
[apiClients.models, environmentName, packageName, modelPath, versionId],
|
|
579
|
+
);
|
|
580
|
+
return (
|
|
581
|
+
<CellRunnerView
|
|
582
|
+
{...props}
|
|
583
|
+
notebook={mounted ? held : undefined}
|
|
584
|
+
runCell={runCell}
|
|
585
|
+
/>
|
|
586
|
+
);
|
|
587
|
+
}
|