@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,143 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { renderHook, waitFor } from "@testing-library/react";
|
|
5
|
+
import { beforeEach, describe, expect, it } from "bun:test";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
import {
|
|
8
|
+
BrowserDocumentStorage,
|
|
9
|
+
DocumentStorageProvider,
|
|
10
|
+
type DocumentStorage,
|
|
11
|
+
} from "../DocumentStorage";
|
|
12
|
+
import { locatorFor } from "../DocumentCreate/documentPath";
|
|
13
|
+
import { findDraftLayout, useDraftLayout } from "./useDraftLayout";
|
|
14
|
+
|
|
15
|
+
describe("findDraftLayout", () => {
|
|
16
|
+
beforeEach(() => localStorage.clear());
|
|
17
|
+
|
|
18
|
+
it("finds the layout a draft was saved with, which the listing cannot say", async () => {
|
|
19
|
+
const storage = new BrowserDocumentStorage();
|
|
20
|
+
// A save records the layout beside the document.
|
|
21
|
+
await storage.saveDocument(
|
|
22
|
+
locatorFor("linear", "Local", "env", "pkg", "story.malloy"),
|
|
23
|
+
"## artifact { layout=linear }",
|
|
24
|
+
);
|
|
25
|
+
await storage.saveDocument(
|
|
26
|
+
locatorFor("grid", "Local", "env", "pkg", "sales/q3.malloy"),
|
|
27
|
+
"## artifact { layout=grid }",
|
|
28
|
+
);
|
|
29
|
+
expect(await findDraftLayout(storage, "env", "pkg", "story.malloy")).toBe(
|
|
30
|
+
"linear",
|
|
31
|
+
);
|
|
32
|
+
expect(
|
|
33
|
+
await findDraftLayout(storage, "env", "pkg", "sales/q3.malloy"),
|
|
34
|
+
).toBe("grid");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("reads the browser store's one document rather than listing them all", async () => {
|
|
38
|
+
const storage = new BrowserDocumentStorage();
|
|
39
|
+
await storage.saveDocument(
|
|
40
|
+
locatorFor("linear", "Local", "env", "pkg", "story.malloy"),
|
|
41
|
+
"x",
|
|
42
|
+
);
|
|
43
|
+
storage.listDocuments = () => {
|
|
44
|
+
throw new Error("listed");
|
|
45
|
+
};
|
|
46
|
+
expect(await findDraftLayout(storage, "env", "pkg", "story.malloy")).toBe(
|
|
47
|
+
"linear",
|
|
48
|
+
);
|
|
49
|
+
expect(
|
|
50
|
+
await findDraftLayout(storage, "env", "pkg", "absent.malloy"),
|
|
51
|
+
).toBeUndefined();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("is undefined when the host keeps no copy, or keeps it for another package", async () => {
|
|
55
|
+
const storage = new BrowserDocumentStorage();
|
|
56
|
+
await storage.saveDocument(
|
|
57
|
+
locatorFor("linear", "Local", "env", "other", "story.malloy"),
|
|
58
|
+
"x",
|
|
59
|
+
);
|
|
60
|
+
expect(
|
|
61
|
+
await findDraftLayout(storage, "env", "pkg", "story.malloy"),
|
|
62
|
+
).toBeUndefined();
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe("useDraftLayout", () => {
|
|
67
|
+
beforeEach(() => localStorage.clear());
|
|
68
|
+
|
|
69
|
+
const withStorage = (storage: DocumentStorage) =>
|
|
70
|
+
function Wrapper({ children }: { children: ReactNode }) {
|
|
71
|
+
return (
|
|
72
|
+
<DocumentStorageProvider documentStorage={storage}>
|
|
73
|
+
{children}
|
|
74
|
+
</DocumentStorageProvider>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
it("is settled at once with no layout when the host keeps no store", () => {
|
|
79
|
+
const { result } = renderHook(() =>
|
|
80
|
+
useDraftLayout("env", "pkg", "story.malloy"),
|
|
81
|
+
);
|
|
82
|
+
expect(result.current).toEqual({ layout: undefined, settled: true });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("is settled at once with no layout when not enabled", () => {
|
|
86
|
+
const { result } = renderHook(
|
|
87
|
+
() => useDraftLayout("env", "pkg", "story.malloy", false),
|
|
88
|
+
{ wrapper: withStorage(new BrowserDocumentStorage()) },
|
|
89
|
+
);
|
|
90
|
+
expect(result.current).toEqual({ layout: undefined, settled: true });
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("is unsettled until the host answers, then has the draft's layout", async () => {
|
|
94
|
+
const storage = new BrowserDocumentStorage();
|
|
95
|
+
await storage.saveDocument(
|
|
96
|
+
locatorFor("linear", "Local", "env", "pkg", "story.malloy"),
|
|
97
|
+
"x",
|
|
98
|
+
);
|
|
99
|
+
const { result } = renderHook(
|
|
100
|
+
() => useDraftLayout("env", "pkg", "story.malloy"),
|
|
101
|
+
{ wrapper: withStorage(storage) },
|
|
102
|
+
);
|
|
103
|
+
expect(result.current).toEqual({ layout: undefined, settled: false });
|
|
104
|
+
await waitFor(() =>
|
|
105
|
+
expect(result.current).toEqual({ layout: "linear", settled: true }),
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("settles with no layout when the host cannot answer", async () => {
|
|
110
|
+
const failing = {
|
|
111
|
+
listWorkspaces: () => Promise.reject(new Error("down")),
|
|
112
|
+
} as unknown as DocumentStorage;
|
|
113
|
+
const { result } = renderHook(
|
|
114
|
+
() => useDraftLayout("env", "pkg", "story.malloy"),
|
|
115
|
+
{ wrapper: withStorage(failing) },
|
|
116
|
+
);
|
|
117
|
+
await waitFor(() =>
|
|
118
|
+
expect(result.current).toEqual({ layout: undefined, settled: true }),
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("asks again for another path, unsettled until it answers", async () => {
|
|
123
|
+
const storage = new BrowserDocumentStorage();
|
|
124
|
+
await storage.saveDocument(
|
|
125
|
+
locatorFor("grid", "Local", "env", "pkg", "b.malloy"),
|
|
126
|
+
"x",
|
|
127
|
+
);
|
|
128
|
+
const { result, rerender } = renderHook(
|
|
129
|
+
({ path }) => useDraftLayout("env", "pkg", path),
|
|
130
|
+
{
|
|
131
|
+
wrapper: withStorage(storage),
|
|
132
|
+
initialProps: { path: "a.malloy" },
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
await waitFor(() => expect(result.current.settled).toBe(true));
|
|
136
|
+
expect(result.current.layout).toBeUndefined();
|
|
137
|
+
rerender({ path: "b.malloy" });
|
|
138
|
+
expect(result.current.settled).toBe(false);
|
|
139
|
+
await waitFor(() =>
|
|
140
|
+
expect(result.current).toEqual({ layout: "grid", settled: true }),
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { chooseWorkspace } from "../ReportBuilder/documentSession";
|
|
6
|
+
import { draftKey } from "../DocumentCreate/documentPath";
|
|
7
|
+
import {
|
|
8
|
+
isDocumentNotFound,
|
|
9
|
+
useOptionalDocumentStorage,
|
|
10
|
+
type DocumentStorage,
|
|
11
|
+
} from "../DocumentStorage";
|
|
12
|
+
import type { ReportLayout } from "./documentLocation";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The layout of the host's copy of the report at `path`, as its store
|
|
16
|
+
* recorded it on the last save, or undefined when it keeps no copy. A report
|
|
17
|
+
* that is only a draft is not in the package's listing, so this is the one
|
|
18
|
+
* place its layout can be read before the editor opens its text; the editor
|
|
19
|
+
* then follows the text. Asks the workspace the editor reads from.
|
|
20
|
+
*/
|
|
21
|
+
export async function findDraftLayout(
|
|
22
|
+
storage: DocumentStorage,
|
|
23
|
+
environmentName: string,
|
|
24
|
+
packageName: string,
|
|
25
|
+
path: string,
|
|
26
|
+
): Promise<ReportLayout | undefined> {
|
|
27
|
+
const workspace = chooseWorkspace(await storage.listWorkspaces(false));
|
|
28
|
+
if (!workspace) return undefined;
|
|
29
|
+
const key = draftKey(environmentName, packageName, path);
|
|
30
|
+
if (storage.getDocumentType) {
|
|
31
|
+
try {
|
|
32
|
+
return await storage.getDocumentType({
|
|
33
|
+
workspace: workspace.name,
|
|
34
|
+
path: key,
|
|
35
|
+
});
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (isDocumentNotFound(error)) return undefined;
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return (await storage.listDocuments(workspace)).find(
|
|
42
|
+
(locator) => locator.path === key,
|
|
43
|
+
)?.type;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* {@link findDraftLayout} for a component: `settled` is false until the host
|
|
48
|
+
* has answered. Without a host store, or when not `enabled`, it is settled at
|
|
49
|
+
* once with no layout. A store that cannot answer settles with no layout too:
|
|
50
|
+
* the editor then opens and reports the read failure itself.
|
|
51
|
+
*/
|
|
52
|
+
export function useDraftLayout(
|
|
53
|
+
environmentName: string,
|
|
54
|
+
packageName: string,
|
|
55
|
+
path: string,
|
|
56
|
+
enabled = true,
|
|
57
|
+
): { layout: ReportLayout | undefined; settled: boolean } {
|
|
58
|
+
const storage = useOptionalDocumentStorage()?.documentStorage;
|
|
59
|
+
const asking = enabled && storage !== undefined;
|
|
60
|
+
const [answer, setAnswer] = useState<{
|
|
61
|
+
key: string;
|
|
62
|
+
layout: ReportLayout | undefined;
|
|
63
|
+
}>();
|
|
64
|
+
const key = draftKey(environmentName, packageName, path);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!asking || !storage) return;
|
|
67
|
+
let stale = false;
|
|
68
|
+
findDraftLayout(storage, environmentName, packageName, path)
|
|
69
|
+
.catch(() => undefined)
|
|
70
|
+
.then((layout) => {
|
|
71
|
+
if (!stale) setAnswer({ key, layout });
|
|
72
|
+
});
|
|
73
|
+
return () => {
|
|
74
|
+
stale = true;
|
|
75
|
+
};
|
|
76
|
+
}, [asking, storage, environmentName, packageName, path, key]);
|
|
77
|
+
if (!asking) return { layout: undefined, settled: true };
|
|
78
|
+
return answer?.key === key
|
|
79
|
+
? { layout: answer.layout, settled: true }
|
|
80
|
+
: { layout: undefined, settled: false };
|
|
81
|
+
}
|
|
@@ -36,14 +36,14 @@ describe("Prose: links", () => {
|
|
|
36
36
|
links={{
|
|
37
37
|
environmentName: "env",
|
|
38
38
|
packageName: "pkg",
|
|
39
|
-
sourcePath: "guides/intro.
|
|
39
|
+
sourcePath: "guides/intro.malloy",
|
|
40
40
|
}}
|
|
41
41
|
>
|
|
42
|
-
{"[next](../sales.
|
|
42
|
+
{"[next](../sales.malloy) [up](../../../etc/passwd)"}
|
|
43
43
|
</Prose>,
|
|
44
44
|
);
|
|
45
45
|
expect(screen.getByText("next").getAttribute("href")).toBe(
|
|
46
|
-
"/env/pkg/sales.
|
|
46
|
+
"/env/pkg/sales.malloy",
|
|
47
47
|
);
|
|
48
48
|
// An escape past the package root is clamped at it, never above.
|
|
49
49
|
expect(screen.getByText("up").getAttribute("href")).toBe(
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
type DrillMetadataSource,
|
|
39
39
|
} from "../drill/markDrillableCells";
|
|
40
40
|
import type { DrillClickPayload } from "../drill/resolveDrill";
|
|
41
|
-
import { loadMalloyTag } from "../
|
|
41
|
+
import { loadMalloyTag } from "../ReportBuilder/loadMalloy";
|
|
42
42
|
import type { DrillBinding } from "../drill/useDrill";
|
|
43
43
|
|
|
44
44
|
type MalloyRenderElement = HTMLElement & Record<string, unknown>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a report written as `run:` cells shows when something fails: a cell
|
|
6
|
+
* the server refuses says why in that cell and leaves the others running, and
|
|
7
|
+
* cells that could not be read at all say so in place of the cells. Rendering
|
|
8
|
+
* the happy path is `Report.spec`'s.
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
afterEach,
|
|
12
|
+
beforeEach,
|
|
13
|
+
describe,
|
|
14
|
+
expect,
|
|
15
|
+
it,
|
|
16
|
+
mock,
|
|
17
|
+
spyOn,
|
|
18
|
+
} from "bun:test";
|
|
19
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
20
|
+
import {
|
|
21
|
+
clearCache,
|
|
22
|
+
mockServerProvider,
|
|
23
|
+
serverWrapper,
|
|
24
|
+
} from "../../../test/serverProvider";
|
|
25
|
+
import type { RawNotebook } from "../../client";
|
|
26
|
+
|
|
27
|
+
let answer: (query: string) => Promise<unknown> = () =>
|
|
28
|
+
Promise.resolve({ data: { result: undefined } });
|
|
29
|
+
const executeQueryModel = mock(
|
|
30
|
+
(
|
|
31
|
+
_environmentName: string,
|
|
32
|
+
_packageName: string,
|
|
33
|
+
_modelPath: string,
|
|
34
|
+
request: { query?: string },
|
|
35
|
+
) => answer(request.query ?? ""),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
mockServerProvider({
|
|
39
|
+
models: { executeQueryModel, getModel: () => new Promise(() => {}) },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Imported after the stub is registered: a static import would hoist above it.
|
|
43
|
+
const { CellReport, CellRunnerView } = await import("./CellReport");
|
|
44
|
+
|
|
45
|
+
const URI = "publisher://environments/env/packages/pkg/models/review.malloy";
|
|
46
|
+
|
|
47
|
+
const cells = (...queries: string[]): RawNotebook =>
|
|
48
|
+
({
|
|
49
|
+
format: "malloy",
|
|
50
|
+
notebookCells: [
|
|
51
|
+
{ type: "markdown", kind: "markdown", text: "Intro prose" },
|
|
52
|
+
...queries.map((text) => ({ type: "code", kind: "query", text })),
|
|
53
|
+
],
|
|
54
|
+
}) as RawNotebook;
|
|
55
|
+
|
|
56
|
+
/** A rejection shaped like axios's, carrying the server's `{message}`. */
|
|
57
|
+
const refused = (message: string) =>
|
|
58
|
+
Object.assign(new Error("Request failed with status code 400"), {
|
|
59
|
+
response: { data: { message } },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// A failed cell is logged as well as shown; the log is not under test.
|
|
63
|
+
let quiet: { mockRestore(): void } | undefined;
|
|
64
|
+
beforeEach(() => {
|
|
65
|
+
clearCache();
|
|
66
|
+
executeQueryModel.mockClear();
|
|
67
|
+
quiet = spyOn(console, "error").mockImplementation(() => {});
|
|
68
|
+
});
|
|
69
|
+
afterEach(() => quiet?.mockRestore());
|
|
70
|
+
|
|
71
|
+
describe("a cell that fails", () => {
|
|
72
|
+
it.each([
|
|
73
|
+
[
|
|
74
|
+
"the server's own message",
|
|
75
|
+
refused("filter 'state' is required"),
|
|
76
|
+
"filter 'state' is required",
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"the error's message when the server sent none",
|
|
80
|
+
new Error("Network Error"),
|
|
81
|
+
"Network Error",
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
"a fixed line when nothing says why",
|
|
85
|
+
"boom",
|
|
86
|
+
"The server did not say why.",
|
|
87
|
+
],
|
|
88
|
+
])("says why with %s, in that cell", async (_name, error, shown) => {
|
|
89
|
+
answer = () => Promise.reject(error);
|
|
90
|
+
render(<CellReport resourceUri={URI} notebook={cells("run: a -> v")} />, {
|
|
91
|
+
wrapper: serverWrapper,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(
|
|
95
|
+
await screen.findByText("This cell could not be run."),
|
|
96
|
+
).toBeTruthy();
|
|
97
|
+
expect(screen.getByText(shown)).toBeTruthy();
|
|
98
|
+
expect(screen.getByText("Intro prose")).toBeTruthy();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("still runs and shows the other cells", async () => {
|
|
102
|
+
answer = (query) =>
|
|
103
|
+
query === "run: bad -> v"
|
|
104
|
+
? Promise.reject(refused("no such source"))
|
|
105
|
+
: Promise.resolve({ data: { result: undefined } });
|
|
106
|
+
render(
|
|
107
|
+
<CellReport
|
|
108
|
+
resourceUri={URI}
|
|
109
|
+
notebook={cells("run: bad -> v", "run: good -> v")}
|
|
110
|
+
/>,
|
|
111
|
+
{ wrapper: serverWrapper },
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
expect(await screen.findByText("no such source")).toBeTruthy();
|
|
115
|
+
expect(executeQueryModel.mock.calls.map((call) => call[3])).toEqual([
|
|
116
|
+
expect.objectContaining({ query: "run: bad -> v" }),
|
|
117
|
+
expect.objectContaining({ query: "run: good -> v" }),
|
|
118
|
+
]);
|
|
119
|
+
expect(screen.getAllByText("This cell could not be run.")).toHaveLength(
|
|
120
|
+
1,
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe("cells that could not be read", () => {
|
|
126
|
+
const view = (error: { status: number; message: string }) =>
|
|
127
|
+
render(
|
|
128
|
+
<CellRunnerView
|
|
129
|
+
resourceUri={URI}
|
|
130
|
+
notebook={undefined}
|
|
131
|
+
error={{
|
|
132
|
+
...error,
|
|
133
|
+
name: "ApiError",
|
|
134
|
+
data: { code: error.status, message: error.message },
|
|
135
|
+
}}
|
|
136
|
+
runCell={() => Promise.resolve({})}
|
|
137
|
+
/>,
|
|
138
|
+
{ wrapper: serverWrapper },
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
it("names the report that does not exist", () => {
|
|
142
|
+
view({ status: 404, message: "Not found" });
|
|
143
|
+
expect(screen.getByText("env > pkg > review.malloy")).toBeTruthy();
|
|
144
|
+
expect(screen.getByText(/not found\./)).toBeTruthy();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("shows any other failure with the report it was reading", async () => {
|
|
148
|
+
view({ status: 500, message: "The package did not load" });
|
|
149
|
+
await waitFor(() =>
|
|
150
|
+
expect(screen.getByText("env > pkg > review.malloy")).toBeTruthy(),
|
|
151
|
+
);
|
|
152
|
+
expect(screen.getByText("The package did not load")).toBeTruthy();
|
|
153
|
+
expect(screen.queryByText(/not found\./)).toBeNull();
|
|
154
|
+
});
|
|
155
|
+
});
|