@malloy-publisher/sdk 0.9.7 → 0.9.8
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-qnpbr4tc.cjs.js → RenderedResult-BrvrMDAP.cjs.js} +1 -1
- package/dist/{RenderedResult-CkUS04tl.es.js → RenderedResult-DZj-FnOJ.es.js} +2 -2
- package/dist/{ServerProvider-DnLLeXEX.es.js → ServerProvider-B_bPAsu2.es.js} +583 -398
- package/dist/ServerProvider-DuEOzwPc.cjs.js +1 -0
- 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 +472 -94
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +105 -95
- 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/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 +7984 -7452
- 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-oocN5cGE.cjs.js +141 -0
- package/dist/{useCompiledDocument-Bf72Ob5v.es.js → useCompiledDocument-x0B2RAH3.es.js} +4593 -4395
- 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/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.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 +173 -292
- 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,277 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { Alert } from "@mui/material";
|
|
5
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
6
|
+
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
7
|
+
import { now } from "../../utils/clock";
|
|
8
|
+
import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
|
|
9
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
10
|
+
import type { NavigationClick } from "../click_helper";
|
|
11
|
+
import { DashboardView } from "../Dashboard/DashboardView";
|
|
12
|
+
import type { TileChrome } from "../Dashboard/TileCard";
|
|
13
|
+
import type { DrillNavigation } from "../drill";
|
|
14
|
+
import { Loading, LOADING_COPY } from "../Loading";
|
|
15
|
+
import { useServer } from "../ServerProvider";
|
|
16
|
+
import { CellReport } from "./CellReport";
|
|
17
|
+
import { LinearReport } from "./LinearReport";
|
|
18
|
+
import {
|
|
19
|
+
failureCategory,
|
|
20
|
+
ReportEventsContext,
|
|
21
|
+
useReportEmitter,
|
|
22
|
+
type DrillOutcome,
|
|
23
|
+
type ReportEventHandler,
|
|
24
|
+
} from "./telemetry";
|
|
25
|
+
|
|
26
|
+
export interface ReportProps {
|
|
27
|
+
/** `publisher://environments/{env}/packages/{pkg}`, optionally `?versionId=`. */
|
|
28
|
+
resourceUri: string;
|
|
29
|
+
/**
|
|
30
|
+
* The report's package path, including `.malloy`, exactly as
|
|
31
|
+
* `GET …/reports` lists it: `sales/q3.malloy`. Its identity. A `.malloynb`
|
|
32
|
+
* the listing also has is rendered by the deprecated `Notebook`, which runs
|
|
33
|
+
* its cells through the only routes that can.
|
|
34
|
+
*/
|
|
35
|
+
path: string;
|
|
36
|
+
/**
|
|
37
|
+
* Control values from the host, typically its URL query parameters. These
|
|
38
|
+
* beat the report's own starting values, so a shared link shows what the
|
|
39
|
+
* sender was looking at.
|
|
40
|
+
*/
|
|
41
|
+
givens?: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* Applied control values, for a host that wants them in its URL.
|
|
44
|
+
*
|
|
45
|
+
* `managed` is every given this report declares, set or not: `givens` alone
|
|
46
|
+
* says which parameters to write but not which to REMOVE.
|
|
47
|
+
*/
|
|
48
|
+
onGivensChange?: (
|
|
49
|
+
givens: Record<string, string>,
|
|
50
|
+
managed: readonly string[],
|
|
51
|
+
) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Where to go when a `# drill` cell is clicked. `target.path` is the
|
|
54
|
+
* tag's `to=` as written: a package path from the root, without `.malloy`,
|
|
55
|
+
* for the host to resolve against `GET …/reports` (`resolveDrillTarget`).
|
|
56
|
+
* Without it, drilling to another report is inert: `to=self` still filters
|
|
57
|
+
* in place. Return what the target resolved to and the drill is reported
|
|
58
|
+
* as a `report.drill` event; return nothing and it is not.
|
|
59
|
+
*/
|
|
60
|
+
onNavigate?: (
|
|
61
|
+
target: DrillNavigation,
|
|
62
|
+
event?: MouseEvent,
|
|
63
|
+
) => DrillOutcome | void;
|
|
64
|
+
/**
|
|
65
|
+
* An ordinary link inside a linear report's prose, for a host with its own
|
|
66
|
+
* router. Omitted, links are plain anchors.
|
|
67
|
+
*/
|
|
68
|
+
onLinkNavigate?: (to: string, event?: NavigationClick) => void;
|
|
69
|
+
/** Height cap for a grid tile's result panel; see `Dashboard`. */
|
|
70
|
+
height?: number;
|
|
71
|
+
maxResultSize?: number;
|
|
72
|
+
/**
|
|
73
|
+
* What the report does — opened, failed to load, a failed query, rows
|
|
74
|
+
* shown, a drill — for the host to log or count; see `ReportEvent`.
|
|
75
|
+
*/
|
|
76
|
+
onEvent?: ReportEventHandler;
|
|
77
|
+
/** A grid report's tile chrome: `card` (default) or `none`. */
|
|
78
|
+
chrome?: TileChrome;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A report of either layout, from `GET …/reports/{path}`: a grid drawn as a
|
|
83
|
+
* dashboard, a linear report top to bottom, and a linear report written as
|
|
84
|
+
* `run:` cells cell by cell, each through the governed query endpoint.
|
|
85
|
+
*
|
|
86
|
+
* Host-agnostic, like `Dashboard`: it takes props rather than reading a
|
|
87
|
+
* router, and hands navigation and URL state back to whoever mounted it.
|
|
88
|
+
*/
|
|
89
|
+
export function Report({
|
|
90
|
+
resourceUri,
|
|
91
|
+
path,
|
|
92
|
+
givens,
|
|
93
|
+
onGivensChange,
|
|
94
|
+
onNavigate,
|
|
95
|
+
onLinkNavigate,
|
|
96
|
+
height,
|
|
97
|
+
maxResultSize,
|
|
98
|
+
onEvent,
|
|
99
|
+
chrome,
|
|
100
|
+
}: ReportProps) {
|
|
101
|
+
const parsed = parseResourceUri(resourceUri);
|
|
102
|
+
const { apiClients } = useServer();
|
|
103
|
+
const environmentName = parsed.environmentName ?? "";
|
|
104
|
+
const packageName = parsed.packageName ?? "";
|
|
105
|
+
const versionId = parsed.versionId;
|
|
106
|
+
const uriNamesBoth = !!parsed.environmentName && !!parsed.packageName;
|
|
107
|
+
|
|
108
|
+
const {
|
|
109
|
+
data: manifest,
|
|
110
|
+
isSuccess,
|
|
111
|
+
isError,
|
|
112
|
+
error,
|
|
113
|
+
} = useQueryWithApiError({
|
|
114
|
+
// Every value the request is built from, so two versions of one report
|
|
115
|
+
// never share a cache entry.
|
|
116
|
+
queryKey: ["report", environmentName, packageName, versionId, path],
|
|
117
|
+
queryFn: async ({ signal }) =>
|
|
118
|
+
(
|
|
119
|
+
await apiClients.reports.getReport(
|
|
120
|
+
environmentName,
|
|
121
|
+
packageName,
|
|
122
|
+
path,
|
|
123
|
+
versionId,
|
|
124
|
+
{ signal },
|
|
125
|
+
)
|
|
126
|
+
).data,
|
|
127
|
+
enabled: uriNamesBoth && path !== "",
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// The layout once the report has said; a `run:`-cell report reads top to bottom.
|
|
131
|
+
const layout = manifest
|
|
132
|
+
? manifest.notebook
|
|
133
|
+
? "linear"
|
|
134
|
+
: manifest.layout
|
|
135
|
+
: undefined;
|
|
136
|
+
const events = useReportEmitter({ path, layout }, onEvent);
|
|
137
|
+
// One open or one failure per report shown: a refetch is not another open,
|
|
138
|
+
// and the guard survives a development double-run of the effect.
|
|
139
|
+
const reportKey = `${resourceUri}|${path}`;
|
|
140
|
+
const reported = useRef<string | undefined>(undefined);
|
|
141
|
+
// Restarted for each report this mount shows, so "opened" times that one.
|
|
142
|
+
const started = useRef({ key: reportKey, at: now() });
|
|
143
|
+
if (started.current.key !== reportKey)
|
|
144
|
+
started.current = { key: reportKey, at: now() };
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (reported.current === reportKey) return;
|
|
147
|
+
if (!uriNamesBoth) {
|
|
148
|
+
reported.current = reportKey;
|
|
149
|
+
events.emit({
|
|
150
|
+
type: "report.load_failed",
|
|
151
|
+
surface: "view",
|
|
152
|
+
category: "invalid",
|
|
153
|
+
});
|
|
154
|
+
} else if (isError) {
|
|
155
|
+
reported.current = reportKey;
|
|
156
|
+
events.emit({
|
|
157
|
+
type: "report.load_failed",
|
|
158
|
+
surface: "view",
|
|
159
|
+
category: failureCategory(error),
|
|
160
|
+
});
|
|
161
|
+
} else if (manifest?.notebook?.format === "malloynb") {
|
|
162
|
+
// Report does not run one; the host renders it with `Notebook`.
|
|
163
|
+
reported.current = reportKey;
|
|
164
|
+
events.emit({
|
|
165
|
+
type: "report.load_failed",
|
|
166
|
+
surface: "view",
|
|
167
|
+
category: "unsupported",
|
|
168
|
+
});
|
|
169
|
+
} else if (isSuccess && manifest) {
|
|
170
|
+
reported.current = reportKey;
|
|
171
|
+
events.emit({
|
|
172
|
+
type: "report.opened",
|
|
173
|
+
surface: "view",
|
|
174
|
+
from: "package",
|
|
175
|
+
tiles: manifest.notebook
|
|
176
|
+
? (manifest.notebook.notebookCells?.length ?? 0)
|
|
177
|
+
: (manifest.tiles?.length ?? 0),
|
|
178
|
+
durationMs: now() - started.current.at,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}, [reportKey, uriNamesBoth, isError, error, isSuccess, manifest, events]);
|
|
182
|
+
// The host resolves a drill to another report; it says what that came to.
|
|
183
|
+
const navigate = useCallback(
|
|
184
|
+
(target: DrillNavigation, event?: MouseEvent) => {
|
|
185
|
+
const outcome = onNavigate?.(target, event);
|
|
186
|
+
if (outcome)
|
|
187
|
+
events.emit({ type: "report.drill", to: "report", outcome });
|
|
188
|
+
},
|
|
189
|
+
[onNavigate, events],
|
|
190
|
+
);
|
|
191
|
+
const drillNavigate = onNavigate ? navigate : undefined;
|
|
192
|
+
|
|
193
|
+
if (!uriNamesBoth) {
|
|
194
|
+
return (
|
|
195
|
+
<Alert severity="error">
|
|
196
|
+
A report resource URI must name an environment and a package.
|
|
197
|
+
Received: {resourceUri}
|
|
198
|
+
</Alert>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
if (isError) {
|
|
202
|
+
return (
|
|
203
|
+
<ApiErrorDisplay
|
|
204
|
+
context={`${environmentName} > ${packageName} > ${path}`}
|
|
205
|
+
error={error}
|
|
206
|
+
/>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
if (!isSuccess || !manifest) {
|
|
210
|
+
return <Loading text={LOADING_COPY.opening("report")} />;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (manifest.notebook?.format === "malloynb") {
|
|
214
|
+
return (
|
|
215
|
+
<Alert severity="info">
|
|
216
|
+
{path} is a .malloynb notebook, which Report does not run: render it
|
|
217
|
+
with Notebook.
|
|
218
|
+
</Alert>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
let body;
|
|
222
|
+
if (manifest.notebook) {
|
|
223
|
+
body = (
|
|
224
|
+
<CellReport
|
|
225
|
+
resourceUri={encodeResourceUri({
|
|
226
|
+
environmentName,
|
|
227
|
+
packageName,
|
|
228
|
+
versionId,
|
|
229
|
+
modelPath: path,
|
|
230
|
+
})}
|
|
231
|
+
notebook={manifest.notebook}
|
|
232
|
+
maxResultSize={maxResultSize}
|
|
233
|
+
givens={givens}
|
|
234
|
+
onGivensChange={onGivensChange}
|
|
235
|
+
onNavigate={onLinkNavigate}
|
|
236
|
+
onDrillNavigate={drillNavigate}
|
|
237
|
+
/>
|
|
238
|
+
);
|
|
239
|
+
} else if (manifest.layout === "linear") {
|
|
240
|
+
body = (
|
|
241
|
+
<LinearReport
|
|
242
|
+
manifest={manifest}
|
|
243
|
+
environmentName={environmentName}
|
|
244
|
+
packageName={packageName}
|
|
245
|
+
versionId={versionId}
|
|
246
|
+
documentName={path}
|
|
247
|
+
givens={givens}
|
|
248
|
+
onGivensChange={onGivensChange}
|
|
249
|
+
onDrillNavigate={drillNavigate}
|
|
250
|
+
maxResultSize={maxResultSize}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
253
|
+
} else {
|
|
254
|
+
body = (
|
|
255
|
+
<DashboardView
|
|
256
|
+
manifest={manifest}
|
|
257
|
+
environmentName={environmentName}
|
|
258
|
+
packageName={packageName}
|
|
259
|
+
versionId={versionId}
|
|
260
|
+
documentName={path}
|
|
261
|
+
givens={givens}
|
|
262
|
+
onGivensChange={onGivensChange}
|
|
263
|
+
onNavigate={drillNavigate}
|
|
264
|
+
height={height}
|
|
265
|
+
maxResultSize={maxResultSize}
|
|
266
|
+
chrome={chrome}
|
|
267
|
+
/>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
return (
|
|
271
|
+
<ReportEventsContext.Provider value={events}>
|
|
272
|
+
{body}
|
|
273
|
+
</ReportEventsContext.Provider>
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export default Report;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
export { Report, type ReportProps } from "./Report";
|
|
5
|
+
export type {
|
|
6
|
+
DrillOutcome,
|
|
7
|
+
ReportEvent,
|
|
8
|
+
ReportEventContext,
|
|
9
|
+
ReportEventHandler,
|
|
10
|
+
ReportFailure,
|
|
11
|
+
SavesTo,
|
|
12
|
+
} from "./telemetry";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
5
|
+
import {
|
|
6
|
+
failureCategory,
|
|
7
|
+
reportEmitter,
|
|
8
|
+
withReportContext,
|
|
9
|
+
type ReportEvent,
|
|
10
|
+
type ReportFailure,
|
|
11
|
+
} from "./telemetry";
|
|
12
|
+
|
|
13
|
+
describe("failureCategory", () => {
|
|
14
|
+
it.each([
|
|
15
|
+
[{ status: 404 }, "not_found"],
|
|
16
|
+
[{ status: 401 }, "forbidden"],
|
|
17
|
+
[{ response: { status: 403 } }, "forbidden"],
|
|
18
|
+
[{ status: 400 }, "invalid"],
|
|
19
|
+
[{ response: { status: 424 } }, "invalid"],
|
|
20
|
+
[{ status: 501 }, "unsupported"],
|
|
21
|
+
[{ response: { status: 503 } }, "server"],
|
|
22
|
+
[{ code: "ERR_NETWORK" }, "network"],
|
|
23
|
+
[new Error("anything"), "unknown"],
|
|
24
|
+
[undefined, "unknown"],
|
|
25
|
+
["a string", "unknown"],
|
|
26
|
+
] as [unknown, ReportFailure][])("reads %j as %s", (error, category) => {
|
|
27
|
+
expect(failureCategory(error)).toBe(category);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("reportEmitter", () => {
|
|
32
|
+
it("stamps each event with the report's path and layout", () => {
|
|
33
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
34
|
+
const { emit, listening } = reportEmitter(
|
|
35
|
+
{ path: "sales/q3.malloy", layout: "grid" },
|
|
36
|
+
onEvent,
|
|
37
|
+
);
|
|
38
|
+
expect(listening).toBe(true);
|
|
39
|
+
emit({ type: "report.save_refused", reason: "x" });
|
|
40
|
+
expect(onEvent.mock.calls[0][0]).toEqual({
|
|
41
|
+
type: "report.save_refused",
|
|
42
|
+
reason: "x",
|
|
43
|
+
path: "sales/q3.malloy",
|
|
44
|
+
layout: "grid",
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("is silent, and says so, when no host listens", () => {
|
|
49
|
+
const { emit, listening } = reportEmitter(
|
|
50
|
+
{ path: "x.malloy" },
|
|
51
|
+
undefined,
|
|
52
|
+
);
|
|
53
|
+
expect(listening).toBe(false);
|
|
54
|
+
expect(() =>
|
|
55
|
+
emit({
|
|
56
|
+
type: "report.load_failed",
|
|
57
|
+
surface: "view",
|
|
58
|
+
category: "unknown",
|
|
59
|
+
}),
|
|
60
|
+
).not.toThrow();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("never lets a sink's own failure reach the surface", () => {
|
|
64
|
+
const { emit } = reportEmitter(
|
|
65
|
+
{ path: "x.malloy", layout: "linear" },
|
|
66
|
+
() => {
|
|
67
|
+
throw new Error("sink down");
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
expect(() =>
|
|
71
|
+
emit({ type: "report.explored", tile: "orders -> by_month" }),
|
|
72
|
+
).not.toThrow();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe("withReportContext", () => {
|
|
77
|
+
it("leaves layout off an event whose report never said", () => {
|
|
78
|
+
expect(
|
|
79
|
+
withReportContext(
|
|
80
|
+
{ type: "report.load_failed", surface: "view", category: "server" },
|
|
81
|
+
{ path: "x.malloy" },
|
|
82
|
+
),
|
|
83
|
+
).toEqual({
|
|
84
|
+
type: "report.load_failed",
|
|
85
|
+
surface: "view",
|
|
86
|
+
category: "server",
|
|
87
|
+
path: "x.malloy",
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { createContext, useContext, useMemo, useRef } from "react";
|
|
5
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Where a Save lands, named by which storage took the write: `package` is the
|
|
9
|
+
* package file on the server, `browser` the Console's own browser store, and
|
|
10
|
+
* `host` a host storage that holds the record. Separate because a save into
|
|
11
|
+
* the package or the record is a change every reader sees, while a browser
|
|
12
|
+
* save is one person's copy on one machine.
|
|
13
|
+
*/
|
|
14
|
+
export type SavesTo = "package" | "browser" | "host";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Why something failed, as a category a sink can count. Never the error's
|
|
18
|
+
* message: that can carry a path, a value or a query the reader typed.
|
|
19
|
+
*/
|
|
20
|
+
export type ReportFailure =
|
|
21
|
+
| "not_found"
|
|
22
|
+
| "forbidden"
|
|
23
|
+
| "invalid"
|
|
24
|
+
| "unsupported"
|
|
25
|
+
| "server"
|
|
26
|
+
| "network"
|
|
27
|
+
| "unknown";
|
|
28
|
+
|
|
29
|
+
/** What a `# drill` click came to. */
|
|
30
|
+
export type DrillOutcome =
|
|
31
|
+
/** It reached a destination: a report the listing has, or this report's own control. */
|
|
32
|
+
| "resolved"
|
|
33
|
+
/** A well-formed destination nothing answers to. */
|
|
34
|
+
| "unresolved"
|
|
35
|
+
/**
|
|
36
|
+
* It navigated to the destination as written before the host could say
|
|
37
|
+
* whether a report is there (its listing not read yet, or unreadable). Not
|
|
38
|
+
* a failure: the page it lands on says what is there.
|
|
39
|
+
*/
|
|
40
|
+
| "unverified"
|
|
41
|
+
/** A target or value that cannot be a destination at all. */
|
|
42
|
+
| "malformed";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Which report an event is about, on every event. `path` is the report's
|
|
46
|
+
* package path (`sales/q3.malloy`); the host that mounted the surface knows
|
|
47
|
+
* the environment and package and adds them when it logs. `layout` is the
|
|
48
|
+
* report's layout when the event happened, which an editor's layout switch
|
|
49
|
+
* changes.
|
|
50
|
+
*/
|
|
51
|
+
export interface ReportEventContext {
|
|
52
|
+
path: string;
|
|
53
|
+
layout: ReportLayout;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* What a report surface reports about itself, for the host to log or count:
|
|
58
|
+
* one event per outcome a reader or author would recognise, each with how long
|
|
59
|
+
* it took where that means anything. Delivered through the `onEvent` prop of
|
|
60
|
+
* `Report`, `ReportEditor`, `ReportBuilder`, `NewDocumentDialog` and
|
|
61
|
+
* `Package`.
|
|
62
|
+
*/
|
|
63
|
+
export type ReportEvent =
|
|
64
|
+
| {
|
|
65
|
+
/**
|
|
66
|
+
* The report could not be opened. `layout` is absent when it failed
|
|
67
|
+
* before the report said what it is.
|
|
68
|
+
*/
|
|
69
|
+
type: "report.load_failed";
|
|
70
|
+
path: string;
|
|
71
|
+
layout?: ReportLayout;
|
|
72
|
+
surface: "view" | "edit";
|
|
73
|
+
category: ReportFailure;
|
|
74
|
+
}
|
|
75
|
+
| (ReportEventContext &
|
|
76
|
+
(
|
|
77
|
+
| {
|
|
78
|
+
type: "report.opened";
|
|
79
|
+
/** The reader's view, or the builder. */
|
|
80
|
+
surface: "view" | "edit";
|
|
81
|
+
/**
|
|
82
|
+
* The package file, a draft the host had saved beside it, or the
|
|
83
|
+
* host's own copy when that copy is the record.
|
|
84
|
+
*/
|
|
85
|
+
from: "package" | "draft" | "record";
|
|
86
|
+
/** Tiles, or cells on a report written as `run:` cells. */
|
|
87
|
+
tiles: number;
|
|
88
|
+
durationMs: number;
|
|
89
|
+
}
|
|
90
|
+
| {
|
|
91
|
+
/** A tile's (or cell's) query failed; `tile` absent means the run as a whole. */
|
|
92
|
+
type: "report.query_failed";
|
|
93
|
+
tile?: number;
|
|
94
|
+
category: ReportFailure;
|
|
95
|
+
}
|
|
96
|
+
| {
|
|
97
|
+
type: "report.rows_shown";
|
|
98
|
+
source: string;
|
|
99
|
+
view: string;
|
|
100
|
+
field: string;
|
|
101
|
+
ok: boolean;
|
|
102
|
+
durationMs: number;
|
|
103
|
+
}
|
|
104
|
+
| { type: "report.explored"; tile: string }
|
|
105
|
+
| {
|
|
106
|
+
type: "report.saved";
|
|
107
|
+
tiles: number;
|
|
108
|
+
/** Whether a tile was added or removed, which moves declarations. */
|
|
109
|
+
structural: boolean;
|
|
110
|
+
/** The save rewrote a report in the cell format as tiles. */
|
|
111
|
+
converted?: boolean;
|
|
112
|
+
where: SavesTo;
|
|
113
|
+
/** The host workspace that took the write; never set for a package save. */
|
|
114
|
+
workspace?: string;
|
|
115
|
+
durationMs: number;
|
|
116
|
+
}
|
|
117
|
+
| { type: "report.save_refused"; reason: string }
|
|
118
|
+
| {
|
|
119
|
+
/** Undo save wrote the file back as it was before the last save. */
|
|
120
|
+
type: "report.save_undone";
|
|
121
|
+
tiles: number;
|
|
122
|
+
structural: boolean;
|
|
123
|
+
where: SavesTo;
|
|
124
|
+
workspace?: string;
|
|
125
|
+
durationMs: number;
|
|
126
|
+
}
|
|
127
|
+
| { type: "report.save_undo_refused"; reason: string }
|
|
128
|
+
| {
|
|
129
|
+
type: "report.created";
|
|
130
|
+
/** Which storage took the write, as on `report.saved`. */
|
|
131
|
+
where: "package" | "host";
|
|
132
|
+
durationMs: number;
|
|
133
|
+
}
|
|
134
|
+
| { type: "report.create_refused"; reason: string }
|
|
135
|
+
| {
|
|
136
|
+
/** The author switched the report between Linear and Grid; `layout` is `to`. */
|
|
137
|
+
type: "report.layout_changed";
|
|
138
|
+
from: ReportLayout;
|
|
139
|
+
to: ReportLayout;
|
|
140
|
+
}
|
|
141
|
+
| {
|
|
142
|
+
type: "report.drill";
|
|
143
|
+
/** `self` filtered this report; `report` went to another. */
|
|
144
|
+
to: "self" | "report";
|
|
145
|
+
outcome: DrillOutcome;
|
|
146
|
+
}
|
|
147
|
+
));
|
|
148
|
+
|
|
149
|
+
export type ReportEventHandler = (event: ReportEvent) => void;
|
|
150
|
+
|
|
151
|
+
type WithoutContext<E> = E extends unknown
|
|
152
|
+
? Omit<E, keyof ReportEventContext>
|
|
153
|
+
: never;
|
|
154
|
+
|
|
155
|
+
/** An event before the surface stamps it with the report it is about. */
|
|
156
|
+
export type ReportEventBody = WithoutContext<ReportEvent>;
|
|
157
|
+
|
|
158
|
+
/** Which report a surface emits for: its layout is unknown until it has read the report. */
|
|
159
|
+
export type ReportEventTarget = Omit<ReportEventContext, "layout"> &
|
|
160
|
+
Partial<Pick<ReportEventContext, "layout">>;
|
|
161
|
+
|
|
162
|
+
/** Stamp an event with its report. */
|
|
163
|
+
export const withReportContext = (
|
|
164
|
+
body: ReportEventBody,
|
|
165
|
+
target: ReportEventTarget,
|
|
166
|
+
): ReportEvent => ({ ...target, ...body }) as ReportEvent;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* How a surface deep inside a report emits: the report fills in which report
|
|
170
|
+
* it is, and a sink's own failure never reaches the reader.
|
|
171
|
+
*/
|
|
172
|
+
export interface ReportEmitter {
|
|
173
|
+
emit: (body: ReportEventBody) => void;
|
|
174
|
+
/**
|
|
175
|
+
* Whether a host is listening. A diagnostic with no other symptom (a cell
|
|
176
|
+
* that failed, a drill that went nowhere) goes to the console only when no
|
|
177
|
+
* host is, so it is never lost and never said twice.
|
|
178
|
+
*/
|
|
179
|
+
listening: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const SILENT: ReportEmitter = { emit: () => {}, listening: false };
|
|
183
|
+
|
|
184
|
+
/** An emitter for one report, or a silent one when no host listens. */
|
|
185
|
+
export function reportEmitter(
|
|
186
|
+
target: ReportEventTarget,
|
|
187
|
+
onEvent: ReportEventHandler | undefined,
|
|
188
|
+
): ReportEmitter {
|
|
189
|
+
if (!onEvent) return SILENT;
|
|
190
|
+
return {
|
|
191
|
+
listening: true,
|
|
192
|
+
emit: (body) => {
|
|
193
|
+
try {
|
|
194
|
+
onEvent(withReportContext(body, target));
|
|
195
|
+
} catch {
|
|
196
|
+
// A sink that throws is the sink's problem, not the reader's.
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* {@link reportEmitter} for a component: stable while the report and whether
|
|
204
|
+
* anyone listens stay the same, so an effect that emits on a change does not
|
|
205
|
+
* emit again because the host passed a new handler.
|
|
206
|
+
*/
|
|
207
|
+
export function useReportEmitter(
|
|
208
|
+
target: ReportEventTarget,
|
|
209
|
+
onEvent: ReportEventHandler | undefined,
|
|
210
|
+
): ReportEmitter {
|
|
211
|
+
const onEventRef = useRef(onEvent);
|
|
212
|
+
onEventRef.current = onEvent;
|
|
213
|
+
const listening = onEvent !== undefined;
|
|
214
|
+
const { path, layout } = target;
|
|
215
|
+
return useMemo(
|
|
216
|
+
() =>
|
|
217
|
+
reportEmitter(
|
|
218
|
+
{ path, ...(layout ? { layout } : {}) },
|
|
219
|
+
listening ? (event) => onEventRef.current?.(event) : undefined,
|
|
220
|
+
),
|
|
221
|
+
[path, layout, listening],
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Set by `Report` around what it renders; silent outside one. */
|
|
226
|
+
export const ReportEventsContext = createContext<ReportEmitter>(SILENT);
|
|
227
|
+
|
|
228
|
+
export const useReportEvents = (): ReportEmitter =>
|
|
229
|
+
useContext(ReportEventsContext);
|
|
230
|
+
|
|
231
|
+
/** The category of a failed request, from its HTTP status or the lack of one. */
|
|
232
|
+
export function failureCategory(error: unknown): ReportFailure {
|
|
233
|
+
const candidate = error as
|
|
234
|
+
| { status?: unknown; response?: { status?: unknown }; code?: unknown }
|
|
235
|
+
| undefined;
|
|
236
|
+
const status =
|
|
237
|
+
typeof candidate?.status === "number"
|
|
238
|
+
? candidate.status
|
|
239
|
+
: typeof candidate?.response?.status === "number"
|
|
240
|
+
? candidate.response.status
|
|
241
|
+
: undefined;
|
|
242
|
+
if (status === undefined)
|
|
243
|
+
return candidate?.code === "ERR_NETWORK" ? "network" : "unknown";
|
|
244
|
+
if (status === 404) return "not_found";
|
|
245
|
+
if (status === 401 || status === 403) return "forbidden";
|
|
246
|
+
if (status === 501) return "unsupported";
|
|
247
|
+
if (status >= 500) return "server";
|
|
248
|
+
if (status >= 400) return "invalid";
|
|
249
|
+
return "unknown";
|
|
250
|
+
}
|
|
@@ -13,7 +13,7 @@ import { FilterDialog } from "./FilterDialog";
|
|
|
13
13
|
import { TileMenu } from "./TileMenu";
|
|
14
14
|
import type { ConversionConfirm } from "./useConversionConfirm";
|
|
15
15
|
import type { useControlBindings } from "./useControlBindings";
|
|
16
|
-
import type {
|
|
16
|
+
import type { ReportEditorHandle } from "./useReportEditor";
|
|
17
17
|
import type { useTileEditing } from "./useTileEditing";
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -33,7 +33,7 @@ export function BuilderDialogs({
|
|
|
33
33
|
confirmConversion,
|
|
34
34
|
exitDialog,
|
|
35
35
|
}: {
|
|
36
|
-
editor:
|
|
36
|
+
editor: ReportEditorHandle;
|
|
37
37
|
catalog: PackageCatalog | undefined;
|
|
38
38
|
columns: number;
|
|
39
39
|
dashboards: string[] | undefined;
|
|
@@ -100,7 +100,7 @@ export function BuilderDialogs({
|
|
|
100
100
|
{...(editor.document.tiles.length === 1 &&
|
|
101
101
|
editor.saved.tiles.length > 0
|
|
102
102
|
? {
|
|
103
|
-
removeBlocked: "A saved
|
|
103
|
+
removeBlocked: "A saved report needs at least one tile.",
|
|
104
104
|
}
|
|
105
105
|
: {})}
|
|
106
106
|
view={menuView}
|
|
@@ -129,8 +129,8 @@ export function BuilderDialogs({
|
|
|
129
129
|
<AppDialog
|
|
130
130
|
open={confirmConversion !== undefined}
|
|
131
131
|
onClose={() => confirmConversion?.stop()}
|
|
132
|
-
title="Convert this
|
|
133
|
-
description="Saving rewrites this
|
|
132
|
+
title="Convert this report?"
|
|
133
|
+
description="Saving rewrites this report in the tile layout. The builder cannot take that back; the file's history in your repository can."
|
|
134
134
|
actions={
|
|
135
135
|
<>
|
|
136
136
|
<Button onClick={() => confirmConversion?.stop()}>
|
|
@@ -24,7 +24,7 @@ import { builderSensors } from "./sortable";
|
|
|
24
24
|
import { TextTileBody } from "./TextTileBody";
|
|
25
25
|
import { GapTarget, GridGuides, TileFrame, TilePlaceholder } from "./TileFrame";
|
|
26
26
|
import { tileDisplayTitle } from "./tileDisplayTitle";
|
|
27
|
-
import type {
|
|
27
|
+
import type { ReportEditorHandle } from "./useReportEditor";
|
|
28
28
|
import type { useTileReorder } from "./useTileReorder";
|
|
29
29
|
import type { useTileResize } from "./useTileResize";
|
|
30
30
|
|
|
@@ -51,7 +51,7 @@ export function BuilderGrid({
|
|
|
51
51
|
editTile,
|
|
52
52
|
renderTile,
|
|
53
53
|
}: {
|
|
54
|
-
editor:
|
|
54
|
+
editor: ReportEditorHandle;
|
|
55
55
|
reorder: ReturnType<typeof useTileReorder>;
|
|
56
56
|
resizing: ReturnType<typeof useTileResize>;
|
|
57
57
|
gridBox: RefObject<HTMLDivElement | null>;
|