@malloy-publisher/sdk 0.9.7 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -17
- package/dist/{RenderedResult-CkUS04tl.es.js → RenderedResult-BHuJpdSn.es.js} +2 -2
- package/dist/{RenderedResult-qnpbr4tc.cjs.js → RenderedResult-Bw7EQc42.cjs.js} +1 -1
- package/dist/ServerProvider-B0dUY8be.cjs.js +1 -0
- package/dist/{ServerProvider-DnLLeXEX.es.js → ServerProvider-CQy4jVYK.es.js} +1602 -1074
- package/dist/builder/index.cjs.js +93 -93
- package/dist/builder/index.es.js +4630 -4562
- package/dist/builder-entry.d.ts +13 -12
- package/dist/client/api.d.ts +893 -104
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +125 -104
- package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
- package/dist/components/Dashboard/DashboardView.d.ts +1 -3
- package/dist/components/Dashboard/index.d.ts +0 -2
- package/dist/components/DocumentCreate/createDocument.d.ts +29 -9
- package/dist/components/DocumentCreate/documentPath.d.ts +21 -6
- package/dist/components/DocumentCreate/guards.d.ts +2 -3
- package/dist/components/DocumentCreate/index.d.ts +2 -3
- package/dist/components/DocumentCreate/newNotebook.d.ts +14 -5
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +6 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +52 -24
- package/dist/components/Loading.d.ts +1 -1
- package/dist/components/Package/ContentTypeIcon.d.ts +3 -3
- package/dist/components/Package/DataSchemaDialog.d.ts +26 -0
- package/dist/components/Package/NewDocumentDialog.d.ts +19 -10
- package/dist/components/Package/Package.d.ts +14 -9
- package/dist/components/Package/documentLocation.d.ts +66 -23
- package/dist/components/Package/index.d.ts +3 -2
- package/dist/components/Package/reportQueries.d.ts +8 -0
- package/dist/components/Package/useDocumentLocation.d.ts +36 -6
- package/dist/components/Package/useDraftLayout.d.ts +20 -0
- package/dist/components/Report/CellReport.d.ts +89 -0
- package/dist/components/Report/LinearReport.d.ts +18 -0
- package/dist/components/Report/Report.d.ts +62 -0
- package/dist/components/Report/index.d.ts +2 -0
- package/dist/components/Report/telemetry.d.ts +163 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.d.ts +5 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/EditorSurface.d.ts +10 -7
- package/dist/components/{DashboardBuilder/DashboardBuilder.d.ts → ReportBuilder/ReportBuilder.d.ts} +17 -8
- package/dist/components/{DashboardBuilder/DashboardEditor.d.ts → ReportBuilder/ReportEditor.d.ts} +41 -14
- package/dist/components/ReportBuilder/builderReport.d.ts +14 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/catalog.d.ts +8 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/document.d.ts +3 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/documentSession.d.ts +1 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/imports.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/malloyTree.d.ts +9 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/newDashboard.d.ts +7 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/readDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/readForEditor.d.ts +1 -1
- package/dist/components/ReportBuilder/reportTag.d.ts +52 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/spliceDocument.d.ts +1 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/useControlBindings.d.ts +2 -2
- package/dist/components/ReportBuilder/useEditorCatalog.d.ts +25 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/useHostCopy.d.ts +5 -3
- package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder/useDashboardEditor.d.ts → ReportBuilder/useReportEditor.d.ts} +3 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.d.ts +6 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/useTileEditing.d.ts +2 -2
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +8 -1
- package/dist/components/drill/useDrillSelf.d.ts +4 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/{Dashboard → legacy}/Dashboard.d.ts +15 -9
- package/dist/components/legacy/MalloynbCells.d.ts +13 -0
- package/dist/components/legacy/Notebook.d.ts +15 -0
- package/dist/components/{DashboardBuilder → legacy}/NotebookEditor.d.ts +3 -3
- package/dist/components/legacy/builderNames.d.ts +10 -0
- package/dist/components/legacy/index.d.ts +11 -0
- package/dist/components/legacy/kindAdapter.d.ts +11 -0
- package/dist/components/legacy/kindTypedDrafts.d.ts +10 -0
- package/dist/components/legacy/nameAlias.d.ts +44 -0
- package/dist/components/legacy/queryKeys.d.ts +8 -0
- package/dist/index.cjs.js +19 -19
- package/dist/index.es.js +8216 -7635
- package/dist/text/index.es.js +2 -2
- package/dist/{text-entry-CA0LZ1xL.es.js → text-entry-72YFLeNk.es.js} +10 -10
- package/dist/{useCompiledDocument-Bf72Ob5v.es.js → useCompiledDocument-1dgF5CC9.es.js} +4593 -4395
- package/dist/useCompiledDocument-BKyRnXmA.cjs.js +141 -0
- package/package.json +2 -2
- package/src/builder-entry.ts +32 -24
- package/src/components/Dashboard/DashboardTile.tsx +17 -0
- package/src/components/Dashboard/DashboardView.spec.tsx +0 -21
- package/src/components/Dashboard/DashboardView.tsx +8 -24
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +1 -4
- package/src/components/Dashboard/index.ts +0 -2
- package/src/components/DocumentCreate/createDocument.spec.ts +346 -53
- package/src/components/DocumentCreate/createDocument.ts +143 -63
- package/src/components/DocumentCreate/documentPath.ts +41 -12
- package/src/components/DocumentCreate/guards.ts +7 -15
- package/src/components/DocumentCreate/index.ts +3 -7
- package/src/components/DocumentCreate/newNotebook.spec.ts +113 -43
- package/src/components/DocumentCreate/newNotebook.ts +32 -10
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +130 -28
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +78 -40
- package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +426 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +57 -24
- package/src/components/Home/AddEnvironmentDialog.tsx +1 -1
- package/src/components/Home/Home.tsx +1 -1
- package/src/components/Loading.tsx +1 -1
- package/src/components/Model/SourcesExplorer.tsx +1 -1
- package/src/components/Notebook/NotebookCell.tsx +6 -5
- package/src/components/Notebook/cellKind.spec.ts +15 -7
- package/src/components/Package/ContentTypeIcon.tsx +16 -3
- package/src/components/Package/DataSchemaDialog.spec.tsx +85 -0
- package/src/components/Package/DataSchemaDialog.tsx +367 -0
- package/src/components/Package/NewDocumentDialog.spec.tsx +145 -88
- package/src/components/Package/NewDocumentDialog.tsx +93 -48
- package/src/components/Package/Package.agents.spec.tsx +76 -0
- package/src/components/Package/Package.artifacts.spec.tsx +79 -60
- package/src/components/Package/Package.create.spec.tsx +126 -112
- package/src/components/Package/Package.notebooks.spec.tsx +46 -27
- package/src/components/Package/Package.spec.tsx +43 -30
- package/src/components/Package/Package.tsx +217 -293
- package/src/components/Package/documentLocation.spec.ts +145 -50
- package/src/components/Package/documentLocation.ts +118 -39
- package/src/components/Package/index.ts +12 -3
- package/src/components/Package/reportQueries.ts +25 -0
- package/src/components/Package/useDocumentLocation.spec.ts +58 -0
- package/src/components/Package/useDocumentLocation.ts +90 -32
- package/src/components/Package/useDraftLayout.spec.tsx +143 -0
- package/src/components/Package/useDraftLayout.ts +81 -0
- package/src/components/Prose.spec.tsx +3 -3
- package/src/components/RenderedResult/RenderedResult.tsx +1 -1
- package/src/components/Report/CellReport.spec.tsx +155 -0
- package/src/components/{Notebook/Notebook.tsx → Report/CellReport.tsx} +178 -220
- package/src/components/Report/LinearReport.tsx +71 -0
- package/src/components/Report/Report.spec.tsx +238 -0
- package/src/components/Report/Report.telemetry.spec.tsx +292 -0
- package/src/components/Report/Report.tsx +277 -0
- package/src/components/Report/index.ts +12 -0
- package/src/components/Report/telemetry.spec.ts +90 -0
- package/src/components/Report/telemetry.ts +250 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.tsx +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.tsx +6 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.tsx +33 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/DrillDialog.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/EditorSurface.tsx +67 -107
- package/src/components/{DashboardBuilder → ReportBuilder}/FilterDialog.tsx +3 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.charts.spec.tsx → ReportBuilder/ReportBuilder.charts.spec.tsx} +4 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.exit.spec.tsx → ReportBuilder/ReportBuilder.exit.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.inline.spec.tsx → ReportBuilder/ReportBuilder.inline.spec.tsx} +4 -4
- package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +145 -0
- package/src/components/{DashboardBuilder/DashboardBuilder.notebook.spec.tsx → ReportBuilder/ReportBuilder.notebook.spec.tsx} +22 -21
- package/src/components/{DashboardBuilder/DashboardBuilder.openDraft.spec.tsx → ReportBuilder/ReportBuilder.openDraft.spec.tsx} +3 -3
- package/src/components/{DashboardBuilder/DashboardBuilder.sources.spec.tsx → ReportBuilder/ReportBuilder.sources.spec.tsx} +19 -8
- package/src/components/{DashboardBuilder/DashboardBuilder.spec.tsx → ReportBuilder/ReportBuilder.spec.tsx} +34 -34
- package/src/components/{DashboardBuilder/DashboardBuilder.textTiles.spec.tsx → ReportBuilder/ReportBuilder.textTiles.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.tsx → ReportBuilder/ReportBuilder.tsx} +46 -21
- package/src/components/{DashboardBuilder/DashboardEditor.authoritative.spec.tsx → ReportBuilder/ReportEditor.authoritative.spec.tsx} +28 -20
- package/src/components/{DashboardBuilder/DashboardEditor.emptyStart.spec.tsx → ReportBuilder/ReportEditor.emptyStart.spec.tsx} +19 -11
- package/src/components/{DashboardBuilder/DashboardEditor.filterTag.spec.tsx → ReportBuilder/ReportEditor.filterTag.spec.tsx} +7 -7
- package/src/components/{DashboardBuilder/DashboardEditor.notebook.spec.tsx → ReportBuilder/ReportEditor.notebook.spec.tsx} +70 -49
- package/src/components/{DashboardBuilder/DashboardEditor.package.spec.tsx → ReportBuilder/ReportEditor.package.spec.tsx} +52 -8
- package/src/components/{DashboardBuilder/DashboardEditor.resourceUri.spec.tsx → ReportBuilder/ReportEditor.resourceUri.spec.tsx} +50 -18
- package/src/components/{DashboardBuilder/DashboardEditor.spec.tsx → ReportBuilder/ReportEditor.spec.tsx} +65 -20
- package/src/components/{DashboardBuilder/DashboardEditor.textSource.spec.tsx → ReportBuilder/ReportEditor.textSource.spec.tsx} +6 -6
- package/src/components/{DashboardBuilder/DashboardEditor.tsx → ReportBuilder/ReportEditor.tsx} +92 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/addTile.compile.spec.ts +1 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/artifactBlock.spec.ts +21 -29
- package/src/components/ReportBuilder/builderReport.ts +53 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.spec.ts +28 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.ts +17 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/controls.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/document.ts +4 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.spec.ts +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.spec.ts +6 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.ts +8 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.chart.spec.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.convert.spec.ts +9 -13
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.read.spec.ts +15 -15
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.ts +7 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.ts +25 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.spec.ts +12 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.ts +11 -24
- package/src/components/{DashboardBuilder → ReportBuilder}/preview.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.spec.ts +64 -36
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.ts +33 -32
- package/src/components/ReportBuilder/readForEditor.spec.ts +96 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readForEditor.ts +3 -11
- package/src/components/ReportBuilder/reportTag.ts +108 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.imports.spec.ts +28 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.spec.ts +32 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.ts +37 -60
- package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.spec.ts +3 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/testing/artifactTagParity.json +2 -2
- package/src/components/ReportBuilder/testing/drillResolution.json +279 -0
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +125 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/textTiles.spec.ts +66 -143
- package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.ts +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/useControlBindings.ts +2 -2
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +156 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +119 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/useHostCopy.ts +7 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.ts +56 -35
- package/src/components/{DashboardBuilder/useDashboardEditor.spec.ts → ReportBuilder/useReportEditor.spec.ts} +6 -6
- package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts} +6 -17
- package/src/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.ts +36 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/useTileEditing.ts +2 -2
- package/src/components/ServerProvider.tsx +2 -0
- package/src/components/drill/resolveDrill.ts +9 -2
- package/src/components/drill/useDrill.tsx +1 -0
- package/src/components/drill/useDrillSelf.spec.tsx +60 -7
- package/src/components/drill/useDrillSelf.ts +29 -12
- package/src/components/index.ts +2 -1
- package/src/components/{Dashboard → legacy}/Dashboard.spec.tsx +1 -1
- package/src/components/{Dashboard → legacy}/Dashboard.tsx +40 -28
- package/src/components/legacy/MalloynbCells.tsx +88 -0
- package/src/components/{Notebook → legacy}/Notebook.served.spec.tsx +17 -13
- package/src/components/{Notebook → legacy}/Notebook.spec.tsx +24 -20
- package/src/components/legacy/Notebook.tsx +44 -0
- package/src/components/{DashboardBuilder → legacy}/NotebookEditor.tsx +7 -4
- package/src/components/legacy/builderNames.ts +25 -0
- package/src/components/legacy/index.ts +20 -0
- package/src/components/legacy/kindAdapter.ts +19 -0
- package/src/components/legacy/kindTypedDrafts.ts +34 -0
- package/src/components/legacy/nameAlias.spec.ts +124 -0
- package/src/components/legacy/nameAlias.ts +95 -0
- package/src/components/legacy/queryKeys.ts +26 -0
- package/src/hooks/useGivensState.spec.ts +9 -9
- package/src/mainEntry.spec.ts +1 -1
- package/src/textEntry.spec.ts +9 -9
- package/src/utils/formatting.spec.ts +5 -5
- package/src/utils/parsing.spec.ts +1 -1
- package/src/utils/parsing.ts +1 -1
- package/dist/ServerProvider-Gj-im5VD.cjs.js +0 -1
- package/dist/components/Dashboard/telemetry.d.ts +0 -73
- package/dist/components/DashboardBuilder/builderReport.d.ts +0 -13
- package/dist/components/DashboardBuilder/telemetry.d.ts +0 -43
- package/dist/components/DocumentCreate/events.d.ts +0 -10
- package/dist/components/Notebook/Notebook.d.ts +0 -52
- package/dist/components/Notebook/index.d.ts +0 -1
- package/dist/useCompiledDocument-tBejqZ7s.cjs.js +0 -142
- package/src/components/Dashboard/telemetry.ts +0 -75
- package/src/components/DashboardBuilder/builderReport.ts +0 -74
- package/src/components/DashboardBuilder/readForEditor.spec.ts +0 -80
- package/src/components/DashboardBuilder/telemetry.ts +0 -47
- package/src/components/DashboardBuilder/testing/documentKindRule.json +0 -40
- package/src/components/DocumentCreate/events.ts +0 -15
- package/src/components/Notebook/index.ts +0 -4
- /package/dist/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/ChartPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/DrillDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterStrip.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TextTileBody.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileFrame.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileMenu.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/annotationText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/changedTile.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/chartLine.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/controls.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/inlineEdit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/layout.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/loadMalloy.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/openDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/preview.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/sortable.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/spliceResult.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tagParse.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/inline.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/resize.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useExitGuard.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useFilterForm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileReorder.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileResize.d.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.render.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/FilterStrip.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineText.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TextTileBody.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileFrame.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileMenu.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/__test__/inventory.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/artifactTagParity.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/catalog.aggregate.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/controls.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/emptyStart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/inlineEdit.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/invariants.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/keepRowStructure.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/layout.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/moveIntoGap.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/openDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.shapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/scannerShapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.chart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceResult.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/statementExtent.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/inline.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/resize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/urlRenderTags.json +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.overlay.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.existing.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/withGaps.spec.ts +0 -0
- /package/src/components/{Notebook → legacy}/Notebook.layout.spec.tsx +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { Box } from "@mui/material";
|
|
5
|
+
import type { DashboardManifest } from "../../client";
|
|
6
|
+
import { DashboardProse, DashboardView } from "../Dashboard/DashboardView";
|
|
7
|
+
import type { DrillNavigation } from "../drill";
|
|
8
|
+
import { CleanNotebookContainer, CleanNotebookSection } from "../styles";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A linear report written as tiles: a one-column grid, its prose drawn bare
|
|
12
|
+
* above the tiles and its controls as a panel.
|
|
13
|
+
*/
|
|
14
|
+
export function LinearReport({
|
|
15
|
+
manifest,
|
|
16
|
+
environmentName,
|
|
17
|
+
packageName,
|
|
18
|
+
versionId,
|
|
19
|
+
documentName,
|
|
20
|
+
givens,
|
|
21
|
+
onGivensChange,
|
|
22
|
+
onDrillNavigate,
|
|
23
|
+
maxResultSize,
|
|
24
|
+
}: {
|
|
25
|
+
/** A report manifest, or the tile layout a deprecated notebook read carries. */
|
|
26
|
+
manifest: DashboardManifest;
|
|
27
|
+
environmentName: string;
|
|
28
|
+
packageName: string;
|
|
29
|
+
versionId: string | undefined;
|
|
30
|
+
documentName: string;
|
|
31
|
+
givens?: Record<string, string>;
|
|
32
|
+
onGivensChange?: (
|
|
33
|
+
givens: Record<string, string>,
|
|
34
|
+
managed: readonly string[],
|
|
35
|
+
) => void;
|
|
36
|
+
onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
37
|
+
maxResultSize?: number;
|
|
38
|
+
}) {
|
|
39
|
+
const { title, description } = manifest;
|
|
40
|
+
return (
|
|
41
|
+
<CleanNotebookContainer>
|
|
42
|
+
<CleanNotebookSection>
|
|
43
|
+
{/* chrome="none" drops the view's own header, so the prose is drawn here. */}
|
|
44
|
+
{(title || description) && (
|
|
45
|
+
<Box sx={{ mb: 2 }}>
|
|
46
|
+
<DashboardProse
|
|
47
|
+
// A linear report's text tiles have no card; its description matches them.
|
|
48
|
+
chrome="none"
|
|
49
|
+
title={title ?? ""}
|
|
50
|
+
{...(description ? { description } : {})}
|
|
51
|
+
/>
|
|
52
|
+
</Box>
|
|
53
|
+
)}
|
|
54
|
+
<DashboardView
|
|
55
|
+
manifest={manifest}
|
|
56
|
+
environmentName={environmentName}
|
|
57
|
+
packageName={packageName}
|
|
58
|
+
versionId={versionId}
|
|
59
|
+
documentName={documentName}
|
|
60
|
+
givens={givens}
|
|
61
|
+
onGivensChange={onGivensChange}
|
|
62
|
+
onNavigate={onDrillNavigate}
|
|
63
|
+
maxResultSize={maxResultSize}
|
|
64
|
+
chrome="none"
|
|
65
|
+
// A linear report's control panel, not a grid's bar.
|
|
66
|
+
controlsLayout="panel"
|
|
67
|
+
/>
|
|
68
|
+
</CleanNotebookSection>
|
|
69
|
+
</CleanNotebookContainer>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `Report` renders a report of either layout from `GET …/reports/{path}`: a
|
|
6
|
+
* grid as a dashboard of carded tiles, a linear report as bare tiles top to
|
|
7
|
+
* bottom, and a report written as `run:` cells cell by cell, through the
|
|
8
|
+
* governed query endpoint. It runs nothing through the deprecated notebooks
|
|
9
|
+
* routes: a `.malloynb` is the deprecated `Notebook`'s to render.
|
|
10
|
+
*/
|
|
11
|
+
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
12
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
13
|
+
import {
|
|
14
|
+
cacheKeys,
|
|
15
|
+
clearCache,
|
|
16
|
+
mockServerProvider,
|
|
17
|
+
pending,
|
|
18
|
+
serverWrapper,
|
|
19
|
+
} from "../../../test/serverProvider";
|
|
20
|
+
import type { ReportManifest } from "../../client";
|
|
21
|
+
|
|
22
|
+
let manifest = {} as ReportManifest;
|
|
23
|
+
const getReport = mock(
|
|
24
|
+
(
|
|
25
|
+
_environmentName: string,
|
|
26
|
+
_packageName: string,
|
|
27
|
+
_path: string,
|
|
28
|
+
_versionId?: string,
|
|
29
|
+
_options?: unknown,
|
|
30
|
+
) => Promise.resolve({ data: manifest }),
|
|
31
|
+
);
|
|
32
|
+
const executeNotebookCell = mock(
|
|
33
|
+
(
|
|
34
|
+
_environmentName: string,
|
|
35
|
+
_packageName: string,
|
|
36
|
+
_path: string,
|
|
37
|
+
_cellIndex: number,
|
|
38
|
+
_versionId?: string,
|
|
39
|
+
_filterParams?: string,
|
|
40
|
+
_bypassFilters?: boolean,
|
|
41
|
+
_givens?: string,
|
|
42
|
+
_options?: unknown,
|
|
43
|
+
): Promise<never> => pending(),
|
|
44
|
+
);
|
|
45
|
+
const getNotebook = mock((): Promise<never> => pending());
|
|
46
|
+
const executeQueryModel = mock(
|
|
47
|
+
(
|
|
48
|
+
_environmentName: string,
|
|
49
|
+
_packageName: string,
|
|
50
|
+
_modelPath: string,
|
|
51
|
+
_request: unknown,
|
|
52
|
+
): Promise<never> => pending(),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
mockServerProvider({
|
|
56
|
+
reports: { getReport },
|
|
57
|
+
notebooks: { getNotebook, executeNotebookCell },
|
|
58
|
+
models: { executeQueryModel, getModel: () => pending() },
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Imported after the stub is registered: a static import would hoist above it.
|
|
62
|
+
const { Report } = await import("./Report");
|
|
63
|
+
|
|
64
|
+
const URI = "publisher://environments/env/packages/pkg";
|
|
65
|
+
|
|
66
|
+
const TILES = {
|
|
67
|
+
path: "sales/q3.malloy",
|
|
68
|
+
name: "q3",
|
|
69
|
+
title: "Third quarter",
|
|
70
|
+
tiles: [{ kind: "query", query: "orders -> by_month" }],
|
|
71
|
+
} as ReportManifest;
|
|
72
|
+
|
|
73
|
+
beforeEach(() => {
|
|
74
|
+
clearCache();
|
|
75
|
+
for (const fn of [
|
|
76
|
+
getReport,
|
|
77
|
+
executeNotebookCell,
|
|
78
|
+
getNotebook,
|
|
79
|
+
executeQueryModel,
|
|
80
|
+
])
|
|
81
|
+
fn.mockClear();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe("the manifest fetch", () => {
|
|
85
|
+
it("reads the report by its path, and keys the read on every value it is built from", async () => {
|
|
86
|
+
manifest = { ...TILES, layout: "grid" };
|
|
87
|
+
render(
|
|
88
|
+
<Report resourceUri={`${URI}?versionId=v2`} path="sales/q3.malloy" />,
|
|
89
|
+
{
|
|
90
|
+
wrapper: serverWrapper,
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
await waitFor(() => expect(getReport).toHaveBeenCalled());
|
|
95
|
+
expect(getReport.mock.calls[0].slice(0, 4)).toEqual([
|
|
96
|
+
"env",
|
|
97
|
+
"pkg",
|
|
98
|
+
"sales/q3.malloy",
|
|
99
|
+
"v2",
|
|
100
|
+
]);
|
|
101
|
+
expect(cacheKeys("report")).toEqual([
|
|
102
|
+
'["report","env","pkg","v2","sales/q3.malloy","http://localhost/api/v0"]',
|
|
103
|
+
]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("keys an unversioned read with an empty version slot", async () => {
|
|
107
|
+
manifest = { ...TILES, layout: "grid" };
|
|
108
|
+
render(<Report resourceUri={URI} path="sales/q3.malloy" />, {
|
|
109
|
+
wrapper: serverWrapper,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
await waitFor(() => expect(getReport).toHaveBeenCalled());
|
|
113
|
+
expect(getReport.mock.calls[0][3]).toBeUndefined();
|
|
114
|
+
expect(cacheKeys("report")).toEqual([
|
|
115
|
+
'["report","env","pkg",null,"sales/q3.malloy","http://localhost/api/v0"]',
|
|
116
|
+
]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("says so, rather than throwing, for a URI that names no package", () => {
|
|
120
|
+
render(
|
|
121
|
+
<Report resourceUri="publisher://environments/env" path="x.malloy" />,
|
|
122
|
+
{
|
|
123
|
+
wrapper: serverWrapper,
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
expect(
|
|
128
|
+
screen.getByText(/must name an environment and a package/),
|
|
129
|
+
).toBeTruthy();
|
|
130
|
+
expect(getReport).not.toHaveBeenCalled();
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe("rendering by layout", () => {
|
|
135
|
+
it("draws a grid report's tiles as cards, run against the report's path", async () => {
|
|
136
|
+
manifest = { ...TILES, layout: "grid" };
|
|
137
|
+
const { container } = render(
|
|
138
|
+
<Report resourceUri={URI} path="sales/q3.malloy" />,
|
|
139
|
+
{ wrapper: serverWrapper },
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
expect(await screen.findByText("Third quarter")).toBeTruthy();
|
|
143
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
144
|
+
expect(executeQueryModel.mock.calls[0][2]).toBe("sales/q3.malloy");
|
|
145
|
+
expect(container.querySelector('[data-chrome="card"]')).not.toBeNull();
|
|
146
|
+
expect(container.querySelector('[data-chrome="none"]')).toBeNull();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("draws a linear report's tiles bare, top to bottom", async () => {
|
|
150
|
+
manifest = { ...TILES, layout: "linear" };
|
|
151
|
+
const { container } = render(
|
|
152
|
+
<Report resourceUri={URI} path="sales/q3.malloy" />,
|
|
153
|
+
{ wrapper: serverWrapper },
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
expect(await screen.findByText("Third quarter")).toBeTruthy();
|
|
157
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
158
|
+
expect(executeQueryModel.mock.calls[0][2]).toBe("sales/q3.malloy");
|
|
159
|
+
await waitFor(() =>
|
|
160
|
+
expect(container.querySelector('[data-chrome="none"]')).not.toBeNull(),
|
|
161
|
+
);
|
|
162
|
+
expect(container.querySelector('[data-chrome="card"]')).toBeNull();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it("runs a .malloy run:-cell report's cells through the query endpoint, against the report itself", async () => {
|
|
166
|
+
manifest = {
|
|
167
|
+
path: "review.malloy",
|
|
168
|
+
name: "review",
|
|
169
|
+
layout: "linear",
|
|
170
|
+
editable: false,
|
|
171
|
+
notebook: {
|
|
172
|
+
format: "malloy",
|
|
173
|
+
notebookCells: [
|
|
174
|
+
{ type: "markdown", kind: "markdown", text: "Cell prose" },
|
|
175
|
+
{
|
|
176
|
+
type: "code",
|
|
177
|
+
kind: "query",
|
|
178
|
+
text: "run: orders -> by_month",
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
},
|
|
182
|
+
} as ReportManifest;
|
|
183
|
+
render(
|
|
184
|
+
<Report resourceUri={`${URI}?versionId=v4`} path="review.malloy" />,
|
|
185
|
+
{
|
|
186
|
+
wrapper: serverWrapper,
|
|
187
|
+
},
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
expect(await screen.findByText("Cell prose")).toBeTruthy();
|
|
191
|
+
await waitFor(() => expect(executeQueryModel).toHaveBeenCalled());
|
|
192
|
+
// The report's path is the model and the cell's text the query, the
|
|
193
|
+
// governed path every grid tile takes.
|
|
194
|
+
expect(
|
|
195
|
+
executeQueryModel.mock.calls.map((call) => call.slice(0, 4)),
|
|
196
|
+
).toEqual([
|
|
197
|
+
[
|
|
198
|
+
"env",
|
|
199
|
+
"pkg",
|
|
200
|
+
"review.malloy",
|
|
201
|
+
{ query: "run: orders -> by_month", givens: {}, versionId: "v4" },
|
|
202
|
+
],
|
|
203
|
+
]);
|
|
204
|
+
expect(executeNotebookCell).not.toHaveBeenCalled();
|
|
205
|
+
// The cells came with the manifest; nothing reads them again.
|
|
206
|
+
expect(getNotebook).not.toHaveBeenCalled();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// DEPRECATED FEATURE COVERAGE — delete together with
|
|
210
|
+
// `.malloynb` notebooks (see RELEASE_NOTES deprecations).
|
|
211
|
+
describe("deprecated: .malloynb notebooks", () => {
|
|
212
|
+
it("says a .malloynb is Notebook's to render, and runs nothing", async () => {
|
|
213
|
+
manifest = {
|
|
214
|
+
path: "legacy.malloynb",
|
|
215
|
+
name: "legacy",
|
|
216
|
+
layout: "linear",
|
|
217
|
+
editable: false,
|
|
218
|
+
notebook: {
|
|
219
|
+
format: "malloynb",
|
|
220
|
+
notebookCells: [
|
|
221
|
+
{ type: "markdown", text: "Legacy prose" },
|
|
222
|
+
{ type: "code", text: "run: orders -> by_month" },
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
} as ReportManifest;
|
|
226
|
+
render(<Report resourceUri={URI} path="legacy.malloynb" />, {
|
|
227
|
+
wrapper: serverWrapper,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
expect(
|
|
231
|
+
await screen.findByText(/render it with Notebook/),
|
|
232
|
+
).toBeTruthy();
|
|
233
|
+
expect(screen.queryByText("Legacy prose")).toBeNull();
|
|
234
|
+
expect(executeNotebookCell).not.toHaveBeenCalled();
|
|
235
|
+
expect(executeQueryModel).not.toHaveBeenCalled();
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
});
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What `Report` tells its host: one `report.opened` or `report.load_failed`
|
|
6
|
+
* per report shown, whatever its layout, and a `report.query_failed` for each
|
|
7
|
+
* tile or cell whose query failed, every event stamped with the report's path
|
|
8
|
+
* and layout.
|
|
9
|
+
*/
|
|
10
|
+
import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test";
|
|
11
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
12
|
+
import {
|
|
13
|
+
clearCache,
|
|
14
|
+
mockServerProvider,
|
|
15
|
+
pending,
|
|
16
|
+
serverWrapper,
|
|
17
|
+
} from "../../../test/serverProvider";
|
|
18
|
+
import type { ReportManifest } from "../../client";
|
|
19
|
+
import type { ReportEvent } from "./telemetry";
|
|
20
|
+
|
|
21
|
+
let manifest = {} as ReportManifest;
|
|
22
|
+
let reportFailure: unknown;
|
|
23
|
+
const getReport = mock(() =>
|
|
24
|
+
reportFailure === undefined
|
|
25
|
+
? Promise.resolve({ data: manifest })
|
|
26
|
+
: Promise.reject(reportFailure),
|
|
27
|
+
);
|
|
28
|
+
let queryFailure: unknown;
|
|
29
|
+
const executeQueryModel = mock(
|
|
30
|
+
(
|
|
31
|
+
_environmentName: string,
|
|
32
|
+
_packageName: string,
|
|
33
|
+
_modelPath: string,
|
|
34
|
+
_request: unknown,
|
|
35
|
+
): Promise<never> =>
|
|
36
|
+
queryFailure === undefined ? pending() : Promise.reject(queryFailure),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
mockServerProvider({
|
|
40
|
+
reports: { getReport },
|
|
41
|
+
models: { executeQueryModel, getModel: () => pending() },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const { Report } = await import("./Report");
|
|
45
|
+
|
|
46
|
+
const URI = "publisher://environments/env/packages/pkg";
|
|
47
|
+
|
|
48
|
+
const GRID = {
|
|
49
|
+
path: "sales/q3.malloy",
|
|
50
|
+
name: "q3",
|
|
51
|
+
title: "Third quarter",
|
|
52
|
+
layout: "grid",
|
|
53
|
+
tiles: [
|
|
54
|
+
{ kind: "query", query: "orders -> by_month" },
|
|
55
|
+
{ kind: "text", name: "note", markdown: "A note" },
|
|
56
|
+
],
|
|
57
|
+
} as ReportManifest;
|
|
58
|
+
|
|
59
|
+
const CELLS = {
|
|
60
|
+
path: "review.malloy",
|
|
61
|
+
name: "review",
|
|
62
|
+
layout: "linear",
|
|
63
|
+
editable: false,
|
|
64
|
+
notebook: {
|
|
65
|
+
format: "malloy",
|
|
66
|
+
notebookCells: [
|
|
67
|
+
{ type: "markdown", kind: "markdown", text: "Cell prose" },
|
|
68
|
+
{ type: "code", kind: "query", text: "run: orders -> by_month" },
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
} as ReportManifest;
|
|
72
|
+
|
|
73
|
+
const typesOf = (calls: [ReportEvent][]) => calls.map(([event]) => event.type);
|
|
74
|
+
|
|
75
|
+
const errorSpy = mock((..._args: unknown[]) => {});
|
|
76
|
+
const realError = console.error;
|
|
77
|
+
|
|
78
|
+
beforeEach(() => {
|
|
79
|
+
clearCache();
|
|
80
|
+
reportFailure = undefined;
|
|
81
|
+
queryFailure = undefined;
|
|
82
|
+
getReport.mockClear();
|
|
83
|
+
executeQueryModel.mockClear();
|
|
84
|
+
errorSpy.mockClear();
|
|
85
|
+
console.error = errorSpy;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
afterEach(() => {
|
|
89
|
+
console.error = realError;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("opening a report", () => {
|
|
93
|
+
it("reports one open of a grid report, with its path, layout and tile count", async () => {
|
|
94
|
+
manifest = GRID;
|
|
95
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
96
|
+
const { rerender } = render(
|
|
97
|
+
<Report resourceUri={URI} path="sales/q3.malloy" onEvent={onEvent} />,
|
|
98
|
+
{ wrapper: serverWrapper },
|
|
99
|
+
);
|
|
100
|
+
expect(await screen.findByText("Third quarter")).toBeTruthy();
|
|
101
|
+
await waitFor(() => expect(onEvent).toHaveBeenCalled());
|
|
102
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
103
|
+
type: "report.opened",
|
|
104
|
+
path: "sales/q3.malloy",
|
|
105
|
+
layout: "grid",
|
|
106
|
+
surface: "view",
|
|
107
|
+
from: "package",
|
|
108
|
+
tiles: 2,
|
|
109
|
+
});
|
|
110
|
+
expect(
|
|
111
|
+
typeof (onEvent.mock.calls[0][0] as { durationMs: number }).durationMs,
|
|
112
|
+
).toBe("number");
|
|
113
|
+
|
|
114
|
+
// A host handing a new handler each render is not a new open.
|
|
115
|
+
const next = mock((_event: ReportEvent) => {});
|
|
116
|
+
rerender(
|
|
117
|
+
<Report resourceUri={URI} path="sales/q3.malloy" onEvent={next} />,
|
|
118
|
+
);
|
|
119
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
120
|
+
expect(typesOf(onEvent.mock.calls)).toEqual(["report.opened"]);
|
|
121
|
+
expect(typesOf(next.mock.calls)).not.toContain("report.opened");
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("reports a linear report's open with its layout", async () => {
|
|
125
|
+
manifest = { ...GRID, layout: "linear" };
|
|
126
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
127
|
+
render(
|
|
128
|
+
<Report resourceUri={URI} path="sales/q3.malloy" onEvent={onEvent} />,
|
|
129
|
+
{ wrapper: serverWrapper },
|
|
130
|
+
);
|
|
131
|
+
await waitFor(() => expect(onEvent).toHaveBeenCalled());
|
|
132
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
133
|
+
type: "report.opened",
|
|
134
|
+
layout: "linear",
|
|
135
|
+
tiles: 2,
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("reports a run:-cell report's open as linear, counting its cells", async () => {
|
|
140
|
+
manifest = CELLS;
|
|
141
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
142
|
+
render(
|
|
143
|
+
<Report resourceUri={URI} path="review.malloy" onEvent={onEvent} />,
|
|
144
|
+
{ wrapper: serverWrapper },
|
|
145
|
+
);
|
|
146
|
+
expect(await screen.findByText("Cell prose")).toBeTruthy();
|
|
147
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
148
|
+
type: "report.opened",
|
|
149
|
+
path: "review.malloy",
|
|
150
|
+
layout: "linear",
|
|
151
|
+
tiles: 2,
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it("reports a failed read as load_failed with a category, never the message, and no open", async () => {
|
|
156
|
+
reportFailure = Object.assign(
|
|
157
|
+
new Error("no such report: secret.malloy"),
|
|
158
|
+
{
|
|
159
|
+
status: 404,
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
163
|
+
render(
|
|
164
|
+
<Report resourceUri={URI} path="secret.malloy" onEvent={onEvent} />,
|
|
165
|
+
{ wrapper: serverWrapper },
|
|
166
|
+
);
|
|
167
|
+
await waitFor(() => expect(onEvent).toHaveBeenCalled());
|
|
168
|
+
expect(onEvent.mock.calls.map(([event]) => event)).toEqual([
|
|
169
|
+
{
|
|
170
|
+
type: "report.load_failed",
|
|
171
|
+
path: "secret.malloy",
|
|
172
|
+
surface: "view",
|
|
173
|
+
category: "not_found",
|
|
174
|
+
},
|
|
175
|
+
]);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("reports a URI that names no package as an invalid load", async () => {
|
|
179
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
180
|
+
render(
|
|
181
|
+
<Report
|
|
182
|
+
resourceUri="publisher://environments/env"
|
|
183
|
+
path="x.malloy"
|
|
184
|
+
onEvent={onEvent}
|
|
185
|
+
/>,
|
|
186
|
+
{ wrapper: serverWrapper },
|
|
187
|
+
);
|
|
188
|
+
await waitFor(() => expect(onEvent).toHaveBeenCalledTimes(1));
|
|
189
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
190
|
+
type: "report.load_failed",
|
|
191
|
+
category: "invalid",
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("keeps rendering when the host's sink throws", async () => {
|
|
196
|
+
manifest = GRID;
|
|
197
|
+
render(
|
|
198
|
+
<Report
|
|
199
|
+
resourceUri={URI}
|
|
200
|
+
path="sales/q3.malloy"
|
|
201
|
+
onEvent={() => {
|
|
202
|
+
throw new Error("sink down");
|
|
203
|
+
}}
|
|
204
|
+
/>,
|
|
205
|
+
{ wrapper: serverWrapper },
|
|
206
|
+
);
|
|
207
|
+
expect(await screen.findByText("Third quarter")).toBeTruthy();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// DEPRECATED FEATURE COVERAGE — delete together with
|
|
211
|
+
// `.malloynb` notebooks (see RELEASE_NOTES deprecations).
|
|
212
|
+
describe("deprecated: .malloynb notebooks", () => {
|
|
213
|
+
it("reports a .malloynb as unsupported rather than opened", async () => {
|
|
214
|
+
manifest = {
|
|
215
|
+
...CELLS,
|
|
216
|
+
path: "legacy.malloynb",
|
|
217
|
+
notebook: { ...CELLS.notebook, format: "malloynb" },
|
|
218
|
+
} as ReportManifest;
|
|
219
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
220
|
+
render(
|
|
221
|
+
<Report
|
|
222
|
+
resourceUri={URI}
|
|
223
|
+
path="legacy.malloynb"
|
|
224
|
+
onEvent={onEvent}
|
|
225
|
+
/>,
|
|
226
|
+
{ wrapper: serverWrapper },
|
|
227
|
+
);
|
|
228
|
+
await waitFor(() => expect(onEvent).toHaveBeenCalled());
|
|
229
|
+
expect(typesOf(onEvent.mock.calls)).toEqual(["report.load_failed"]);
|
|
230
|
+
expect(onEvent.mock.calls[0][0]).toMatchObject({
|
|
231
|
+
category: "unsupported",
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
describe("a failed query", () => {
|
|
238
|
+
it("reports a grid tile's failure once, by position and category", async () => {
|
|
239
|
+
manifest = GRID;
|
|
240
|
+
queryFailure = { response: { status: 500 } };
|
|
241
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
242
|
+
render(
|
|
243
|
+
<Report resourceUri={URI} path="sales/q3.malloy" onEvent={onEvent} />,
|
|
244
|
+
{ wrapper: serverWrapper },
|
|
245
|
+
);
|
|
246
|
+
await waitFor(() =>
|
|
247
|
+
expect(typesOf(onEvent.mock.calls)).toContain("report.query_failed"),
|
|
248
|
+
);
|
|
249
|
+
await new Promise((resolve) => setTimeout(resolve, 20));
|
|
250
|
+
const failures = onEvent.mock.calls
|
|
251
|
+
.map(([event]) => event)
|
|
252
|
+
.filter((event) => event.type === "report.query_failed");
|
|
253
|
+
expect(failures).toEqual([
|
|
254
|
+
{
|
|
255
|
+
type: "report.query_failed",
|
|
256
|
+
path: "sales/q3.malloy",
|
|
257
|
+
layout: "grid",
|
|
258
|
+
tile: 0,
|
|
259
|
+
category: "server",
|
|
260
|
+
},
|
|
261
|
+
]);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("reports a cell's failure to the host instead of the console", async () => {
|
|
265
|
+
manifest = CELLS;
|
|
266
|
+
queryFailure = { response: { status: 403 } };
|
|
267
|
+
const onEvent = mock((_event: ReportEvent) => {});
|
|
268
|
+
render(
|
|
269
|
+
<Report resourceUri={URI} path="review.malloy" onEvent={onEvent} />,
|
|
270
|
+
{ wrapper: serverWrapper },
|
|
271
|
+
);
|
|
272
|
+
await waitFor(() =>
|
|
273
|
+
expect(typesOf(onEvent.mock.calls)).toContain("report.query_failed"),
|
|
274
|
+
);
|
|
275
|
+
expect(
|
|
276
|
+
onEvent.mock.calls
|
|
277
|
+
.map(([event]) => event)
|
|
278
|
+
.find((event) => event.type === "report.query_failed"),
|
|
279
|
+
).toMatchObject({ tile: 1, category: "forbidden", layout: "linear" });
|
|
280
|
+
expect(errorSpy).not.toHaveBeenCalled();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it("logs a cell's failure to the console when no host listens", async () => {
|
|
284
|
+
manifest = CELLS;
|
|
285
|
+
queryFailure = { response: { status: 500 } };
|
|
286
|
+
render(<Report resourceUri={URI} path="review.malloy" />, {
|
|
287
|
+
wrapper: serverWrapper,
|
|
288
|
+
});
|
|
289
|
+
await waitFor(() => expect(errorSpy).toHaveBeenCalled());
|
|
290
|
+
expect(String(errorSpy.mock.calls[0][0])).toContain("cell 1");
|
|
291
|
+
});
|
|
292
|
+
});
|