@malloy-publisher/sdk 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +117 -17
- package/dist/{RenderedResult-qnpbr4tc.cjs.js → RenderedResult-BrvrMDAP.cjs.js} +1 -1
- package/dist/{RenderedResult-CkUS04tl.es.js → RenderedResult-DZj-FnOJ.es.js} +2 -2
- package/dist/{ServerProvider-DnLLeXEX.es.js → ServerProvider-B_bPAsu2.es.js} +583 -398
- package/dist/ServerProvider-DuEOzwPc.cjs.js +1 -0
- package/dist/builder/index.cjs.js +93 -93
- package/dist/builder/index.es.js +4630 -4562
- package/dist/builder-entry.d.ts +13 -12
- package/dist/client/api.d.ts +472 -94
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +105 -95
- package/dist/components/Dashboard/DashboardTile.d.ts +3 -1
- package/dist/components/Dashboard/DashboardView.d.ts +1 -3
- package/dist/components/Dashboard/index.d.ts +0 -2
- package/dist/components/DocumentCreate/createDocument.d.ts +29 -9
- package/dist/components/DocumentCreate/documentPath.d.ts +21 -6
- package/dist/components/DocumentCreate/guards.d.ts +2 -3
- package/dist/components/DocumentCreate/index.d.ts +2 -3
- package/dist/components/DocumentCreate/newNotebook.d.ts +14 -5
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +6 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +52 -24
- package/dist/components/Loading.d.ts +1 -1
- package/dist/components/Package/DataSchemaDialog.d.ts +26 -0
- package/dist/components/Package/NewDocumentDialog.d.ts +19 -10
- package/dist/components/Package/Package.d.ts +14 -9
- package/dist/components/Package/documentLocation.d.ts +66 -23
- package/dist/components/Package/index.d.ts +3 -2
- package/dist/components/Package/reportQueries.d.ts +8 -0
- package/dist/components/Package/useDocumentLocation.d.ts +36 -6
- package/dist/components/Package/useDraftLayout.d.ts +20 -0
- package/dist/components/Report/CellReport.d.ts +89 -0
- package/dist/components/Report/LinearReport.d.ts +18 -0
- package/dist/components/Report/Report.d.ts +62 -0
- package/dist/components/Report/index.d.ts +2 -0
- package/dist/components/Report/telemetry.d.ts +163 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.d.ts +5 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/EditorSurface.d.ts +10 -7
- package/dist/components/{DashboardBuilder/DashboardBuilder.d.ts → ReportBuilder/ReportBuilder.d.ts} +17 -8
- package/dist/components/{DashboardBuilder/DashboardEditor.d.ts → ReportBuilder/ReportEditor.d.ts} +41 -14
- package/dist/components/ReportBuilder/builderReport.d.ts +14 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/catalog.d.ts +8 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/document.d.ts +3 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/documentSession.d.ts +1 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/imports.d.ts +5 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/malloyTree.d.ts +9 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/newDashboard.d.ts +7 -1
- package/dist/components/{DashboardBuilder → ReportBuilder}/readDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder → ReportBuilder}/readForEditor.d.ts +1 -1
- package/dist/components/ReportBuilder/reportTag.d.ts +52 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/spliceDocument.d.ts +1 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.d.ts +2 -2
- package/dist/components/{DashboardBuilder → ReportBuilder}/useControlBindings.d.ts +2 -2
- package/dist/components/ReportBuilder/useEditorCatalog.d.ts +25 -0
- package/dist/components/{DashboardBuilder → ReportBuilder}/useHostCopy.d.ts +5 -3
- package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.d.ts +7 -5
- package/dist/components/{DashboardBuilder/useDashboardEditor.d.ts → ReportBuilder/useReportEditor.d.ts} +3 -7
- package/dist/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.d.ts +6 -4
- package/dist/components/{DashboardBuilder → ReportBuilder}/useTileEditing.d.ts +2 -2
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +8 -1
- package/dist/components/drill/useDrillSelf.d.ts +4 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/{Dashboard → legacy}/Dashboard.d.ts +15 -9
- package/dist/components/legacy/MalloynbCells.d.ts +13 -0
- package/dist/components/legacy/Notebook.d.ts +15 -0
- package/dist/components/{DashboardBuilder → legacy}/NotebookEditor.d.ts +3 -3
- package/dist/components/legacy/builderNames.d.ts +10 -0
- package/dist/components/legacy/index.d.ts +11 -0
- package/dist/components/legacy/kindAdapter.d.ts +11 -0
- package/dist/components/legacy/kindTypedDrafts.d.ts +10 -0
- package/dist/components/legacy/nameAlias.d.ts +44 -0
- package/dist/components/legacy/queryKeys.d.ts +8 -0
- package/dist/index.cjs.js +19 -19
- package/dist/index.es.js +7984 -7452
- package/dist/text/index.es.js +2 -2
- package/dist/{text-entry-CA0LZ1xL.es.js → text-entry-72YFLeNk.es.js} +10 -10
- package/dist/useCompiledDocument-oocN5cGE.cjs.js +141 -0
- package/dist/{useCompiledDocument-Bf72Ob5v.es.js → useCompiledDocument-x0B2RAH3.es.js} +4593 -4395
- package/package.json +2 -2
- package/src/builder-entry.ts +32 -24
- package/src/components/Dashboard/DashboardTile.tsx +17 -0
- package/src/components/Dashboard/DashboardView.spec.tsx +0 -21
- package/src/components/Dashboard/DashboardView.tsx +8 -24
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +1 -4
- package/src/components/Dashboard/index.ts +0 -2
- package/src/components/DocumentCreate/createDocument.spec.ts +346 -53
- package/src/components/DocumentCreate/createDocument.ts +143 -63
- package/src/components/DocumentCreate/documentPath.ts +41 -12
- package/src/components/DocumentCreate/guards.ts +7 -15
- package/src/components/DocumentCreate/index.ts +3 -7
- package/src/components/DocumentCreate/newNotebook.spec.ts +113 -43
- package/src/components/DocumentCreate/newNotebook.ts +32 -10
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +130 -28
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +78 -40
- package/src/components/DocumentStorage/DocumentStorage.contract.spec.tsx +426 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +57 -24
- package/src/components/Home/AddEnvironmentDialog.tsx +1 -1
- package/src/components/Home/Home.tsx +1 -1
- package/src/components/Loading.tsx +1 -1
- package/src/components/Model/SourcesExplorer.tsx +1 -1
- package/src/components/Notebook/NotebookCell.tsx +6 -5
- package/src/components/Notebook/cellKind.spec.ts +15 -7
- package/src/components/Package/DataSchemaDialog.spec.tsx +85 -0
- package/src/components/Package/DataSchemaDialog.tsx +367 -0
- package/src/components/Package/NewDocumentDialog.spec.tsx +145 -88
- package/src/components/Package/NewDocumentDialog.tsx +93 -48
- package/src/components/Package/Package.artifacts.spec.tsx +79 -60
- package/src/components/Package/Package.create.spec.tsx +126 -112
- package/src/components/Package/Package.notebooks.spec.tsx +46 -27
- package/src/components/Package/Package.spec.tsx +43 -30
- package/src/components/Package/Package.tsx +173 -292
- package/src/components/Package/documentLocation.spec.ts +145 -50
- package/src/components/Package/documentLocation.ts +118 -39
- package/src/components/Package/index.ts +12 -3
- package/src/components/Package/reportQueries.ts +25 -0
- package/src/components/Package/useDocumentLocation.spec.ts +58 -0
- package/src/components/Package/useDocumentLocation.ts +90 -32
- package/src/components/Package/useDraftLayout.spec.tsx +143 -0
- package/src/components/Package/useDraftLayout.ts +81 -0
- package/src/components/Prose.spec.tsx +3 -3
- package/src/components/RenderedResult/RenderedResult.tsx +1 -1
- package/src/components/Report/CellReport.spec.tsx +155 -0
- package/src/components/{Notebook/Notebook.tsx → Report/CellReport.tsx} +178 -220
- package/src/components/Report/LinearReport.tsx +71 -0
- package/src/components/Report/Report.spec.tsx +238 -0
- package/src/components/Report/Report.telemetry.spec.tsx +292 -0
- package/src/components/Report/Report.tsx +277 -0
- package/src/components/Report/index.ts +12 -0
- package/src/components/Report/telemetry.spec.ts +90 -0
- package/src/components/Report/telemetry.ts +250 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderDialogs.tsx +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderGrid.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderHeader.tsx +6 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/BuilderToolbar.tsx +33 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/DrillDialog.tsx +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/EditorSurface.tsx +67 -107
- package/src/components/{DashboardBuilder → ReportBuilder}/FilterDialog.tsx +3 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.charts.spec.tsx → ReportBuilder/ReportBuilder.charts.spec.tsx} +4 -4
- package/src/components/{DashboardBuilder/DashboardBuilder.exit.spec.tsx → ReportBuilder/ReportBuilder.exit.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.inline.spec.tsx → ReportBuilder/ReportBuilder.inline.spec.tsx} +4 -4
- package/src/components/ReportBuilder/ReportBuilder.layoutSwitch.spec.tsx +145 -0
- package/src/components/{DashboardBuilder/DashboardBuilder.notebook.spec.tsx → ReportBuilder/ReportBuilder.notebook.spec.tsx} +22 -21
- package/src/components/{DashboardBuilder/DashboardBuilder.openDraft.spec.tsx → ReportBuilder/ReportBuilder.openDraft.spec.tsx} +3 -3
- package/src/components/{DashboardBuilder/DashboardBuilder.sources.spec.tsx → ReportBuilder/ReportBuilder.sources.spec.tsx} +19 -8
- package/src/components/{DashboardBuilder/DashboardBuilder.spec.tsx → ReportBuilder/ReportBuilder.spec.tsx} +34 -34
- package/src/components/{DashboardBuilder/DashboardBuilder.textTiles.spec.tsx → ReportBuilder/ReportBuilder.textTiles.spec.tsx} +5 -5
- package/src/components/{DashboardBuilder/DashboardBuilder.tsx → ReportBuilder/ReportBuilder.tsx} +46 -21
- package/src/components/{DashboardBuilder/DashboardEditor.authoritative.spec.tsx → ReportBuilder/ReportEditor.authoritative.spec.tsx} +28 -20
- package/src/components/{DashboardBuilder/DashboardEditor.emptyStart.spec.tsx → ReportBuilder/ReportEditor.emptyStart.spec.tsx} +19 -11
- package/src/components/{DashboardBuilder/DashboardEditor.filterTag.spec.tsx → ReportBuilder/ReportEditor.filterTag.spec.tsx} +7 -7
- package/src/components/{DashboardBuilder/DashboardEditor.notebook.spec.tsx → ReportBuilder/ReportEditor.notebook.spec.tsx} +70 -49
- package/src/components/{DashboardBuilder/DashboardEditor.package.spec.tsx → ReportBuilder/ReportEditor.package.spec.tsx} +52 -8
- package/src/components/{DashboardBuilder/DashboardEditor.resourceUri.spec.tsx → ReportBuilder/ReportEditor.resourceUri.spec.tsx} +50 -18
- package/src/components/{DashboardBuilder/DashboardEditor.spec.tsx → ReportBuilder/ReportEditor.spec.tsx} +65 -20
- package/src/components/{DashboardBuilder/DashboardEditor.textSource.spec.tsx → ReportBuilder/ReportEditor.textSource.spec.tsx} +6 -6
- package/src/components/{DashboardBuilder/DashboardEditor.tsx → ReportBuilder/ReportEditor.tsx} +92 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/addTile.compile.spec.ts +1 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/artifactBlock.spec.ts +21 -29
- package/src/components/ReportBuilder/builderReport.ts +53 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.spec.ts +28 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/catalog.ts +17 -10
- package/src/components/{DashboardBuilder → ReportBuilder}/controls.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/document.ts +4 -7
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.spec.ts +5 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/documentSession.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.spec.ts +6 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/imports.ts +8 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.chart.spec.ts +1 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.convert.spec.ts +9 -13
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.read.spec.ts +15 -15
- package/src/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.ts +7 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.ts +25 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.spec.ts +12 -4
- package/src/components/{DashboardBuilder → ReportBuilder}/newDashboard.ts +11 -24
- package/src/components/{DashboardBuilder → ReportBuilder}/preview.spec.ts +1 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.spec.ts +64 -36
- package/src/components/{DashboardBuilder → ReportBuilder}/readDocument.ts +33 -32
- package/src/components/ReportBuilder/readForEditor.spec.ts +96 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/readForEditor.ts +3 -11
- package/src/components/ReportBuilder/reportTag.ts +108 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.imports.spec.ts +28 -1
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.spec.ts +32 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.ts +37 -60
- package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.spec.ts +3 -3
- package/src/components/{DashboardBuilder → ReportBuilder}/testing/artifactTagParity.json +2 -2
- package/src/components/ReportBuilder/testing/drillResolution.json +279 -0
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +125 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/textTiles.spec.ts +66 -143
- package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSelection.ts +2 -2
- package/src/components/{DashboardBuilder → ReportBuilder}/useControlBindings.ts +2 -2
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +156 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +119 -0
- package/src/components/{DashboardBuilder → ReportBuilder}/useHostCopy.ts +7 -5
- package/src/components/{DashboardBuilder → ReportBuilder}/useOpenedDocument.ts +56 -35
- package/src/components/{DashboardBuilder/useDashboardEditor.spec.ts → ReportBuilder/useReportEditor.spec.ts} +6 -6
- package/src/components/{DashboardBuilder/useDashboardEditor.ts → ReportBuilder/useReportEditor.ts} +6 -17
- package/src/components/{DashboardBuilder → ReportBuilder}/useSaveChannel.ts +36 -35
- package/src/components/{DashboardBuilder → ReportBuilder}/useTileEditing.ts +2 -2
- package/src/components/ServerProvider.tsx +2 -0
- package/src/components/drill/resolveDrill.ts +9 -2
- package/src/components/drill/useDrill.tsx +1 -0
- package/src/components/drill/useDrillSelf.spec.tsx +60 -7
- package/src/components/drill/useDrillSelf.ts +29 -12
- package/src/components/index.ts +2 -1
- package/src/components/{Dashboard → legacy}/Dashboard.spec.tsx +1 -1
- package/src/components/{Dashboard → legacy}/Dashboard.tsx +40 -28
- package/src/components/legacy/MalloynbCells.tsx +88 -0
- package/src/components/{Notebook → legacy}/Notebook.served.spec.tsx +17 -13
- package/src/components/{Notebook → legacy}/Notebook.spec.tsx +24 -20
- package/src/components/legacy/Notebook.tsx +44 -0
- package/src/components/{DashboardBuilder → legacy}/NotebookEditor.tsx +7 -4
- package/src/components/legacy/builderNames.ts +25 -0
- package/src/components/legacy/index.ts +20 -0
- package/src/components/legacy/kindAdapter.ts +19 -0
- package/src/components/legacy/kindTypedDrafts.ts +34 -0
- package/src/components/legacy/nameAlias.spec.ts +124 -0
- package/src/components/legacy/nameAlias.ts +95 -0
- package/src/components/legacy/queryKeys.ts +26 -0
- package/src/hooks/useGivensState.spec.ts +9 -9
- package/src/mainEntry.spec.ts +1 -1
- package/src/textEntry.spec.ts +9 -9
- package/src/utils/formatting.spec.ts +5 -5
- package/src/utils/parsing.spec.ts +1 -1
- package/src/utils/parsing.ts +1 -1
- package/dist/ServerProvider-Gj-im5VD.cjs.js +0 -1
- package/dist/components/Dashboard/telemetry.d.ts +0 -73
- package/dist/components/DashboardBuilder/builderReport.d.ts +0 -13
- package/dist/components/DashboardBuilder/telemetry.d.ts +0 -43
- package/dist/components/DocumentCreate/events.d.ts +0 -10
- package/dist/components/Notebook/Notebook.d.ts +0 -52
- package/dist/components/Notebook/index.d.ts +0 -1
- package/dist/useCompiledDocument-tBejqZ7s.cjs.js +0 -142
- package/src/components/Dashboard/telemetry.ts +0 -75
- package/src/components/DashboardBuilder/builderReport.ts +0 -74
- package/src/components/DashboardBuilder/readForEditor.spec.ts +0 -80
- package/src/components/DashboardBuilder/telemetry.ts +0 -47
- package/src/components/DashboardBuilder/testing/documentKindRule.json +0 -40
- package/src/components/DocumentCreate/events.ts +0 -15
- package/src/components/Notebook/index.ts +0 -4
- /package/dist/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/ChartPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/DrillDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterDialog.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/FilterStrip.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/InlineText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TextTileBody.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileFrame.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/TileMenu.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/annotationText.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/changedTile.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/chartLine.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/controls.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/inlineEdit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/layout.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/legacyNotebook.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/loadMalloy.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/openDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/preview.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/sortable.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/spliceResult.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tagParse.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/inline.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/testing/resize.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useDraft.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useExitGuard.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useFilterForm.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileReorder.d.ts +0 -0
- /package/dist/components/{DashboardBuilder → ReportBuilder}/useTileResize.d.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/AddTileDialog.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.render.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/ChartPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/FilterStrip.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineMarkdown.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/InlineText.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/SourceViewPicker.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TextTileBody.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileFrame.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/TileMenu.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/__test__/inventory.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/addTileToDocument.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/annotationText.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/artifactTagParity.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/catalog.aggregate.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/changedTile.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/chartLine.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/controls.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/emptyStart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/inlineEdit.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/invariants.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/keepRowStructure.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/layout.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/loadMalloy.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/malloyTree.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/moveIntoGap.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/openDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.shapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/preview.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/scannerShapes.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/sortable.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceDocument.chart.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/spliceResult.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/statementExtent.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tagParse.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/fixtures.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/inline.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/resize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/testing/urlRenderTags.json +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/tileDisplayTitle.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderSession.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.overlay.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useBuilderShortcuts.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useConversionConfirm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDocumentEditor.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useDraft.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.spec.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useExitGuard.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.existing.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useFilterForm.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useOpenDraftCommit.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileReorder.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.spec.tsx +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/useTileResize.ts +0 -0
- /package/src/components/{DashboardBuilder → ReportBuilder}/withGaps.spec.ts +0 -0
- /package/src/components/{Notebook → legacy}/Notebook.layout.spec.tsx +0 -0
|
@@ -2,80 +2,175 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import * as fs from "fs";
|
|
6
|
+
import * as path from "path";
|
|
5
7
|
import {
|
|
6
|
-
documentRoute,
|
|
7
8
|
documentSlug,
|
|
8
|
-
|
|
9
|
+
locateReport,
|
|
10
|
+
reportEditRoute,
|
|
11
|
+
reportRoute,
|
|
12
|
+
reportRoutePath,
|
|
13
|
+
resolveDrillTarget,
|
|
9
14
|
} from "./documentLocation";
|
|
10
15
|
|
|
11
16
|
describe("documentSlug", () => {
|
|
12
|
-
it("
|
|
17
|
+
it("is the basename of any path, at any depth", () => {
|
|
18
|
+
expect(documentSlug("tour.malloy")).toBe("tour");
|
|
13
19
|
expect(documentSlug("notebooks/tour.malloy")).toBe("tour");
|
|
14
20
|
expect(documentSlug("dashboards/tour.malloy")).toBe("tour");
|
|
21
|
+
expect(documentSlug("sales/2024/q3.malloy")).toBe("q3");
|
|
15
22
|
});
|
|
16
23
|
|
|
17
|
-
it("
|
|
18
|
-
expect(documentSlug("
|
|
19
|
-
expect(documentSlug("
|
|
20
|
-
|
|
24
|
+
it("drops a .malloynb suffix too", () => {
|
|
25
|
+
expect(documentSlug("README.malloynb")).toBe("README");
|
|
26
|
+
expect(documentSlug("old/orders.malloynb")).toBe("orders");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("is undefined for no path", () => {
|
|
21
30
|
expect(documentSlug(undefined)).toBeUndefined();
|
|
31
|
+
expect(documentSlug("")).toBeUndefined();
|
|
22
32
|
});
|
|
23
33
|
});
|
|
24
34
|
|
|
25
|
-
describe("
|
|
26
|
-
it("
|
|
27
|
-
expect(
|
|
28
|
-
"/env/pkg/
|
|
35
|
+
describe("reportRoute", () => {
|
|
36
|
+
it("is the package path without .malloy, each segment encoded", () => {
|
|
37
|
+
expect(reportRoute("env", "pkg", "sales/q3.malloy")).toBe(
|
|
38
|
+
"/env/pkg/sales/q3",
|
|
39
|
+
);
|
|
40
|
+
expect(reportRoutePath("a#b/c d.malloy")).toBe("a%23b/c%20d");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("edits with ?edit, so a report named edit keeps its own route", () => {
|
|
44
|
+
expect(reportEditRoute("env", "pkg", "sales/q3.malloy")).toBe(
|
|
45
|
+
"/env/pkg/sales/q3?edit",
|
|
46
|
+
);
|
|
47
|
+
expect(reportRoute("env", "pkg", "sales/edit.malloy")).toBe(
|
|
48
|
+
"/env/pkg/sales/edit",
|
|
49
|
+
);
|
|
50
|
+
expect(reportEditRoute("env", "pkg", "sales/edit.malloy")).toBe(
|
|
51
|
+
"/env/pkg/sales/edit?edit",
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("keeps a .malloynb suffix, which opens by path", () => {
|
|
56
|
+
expect(reportRoutePath("old.malloynb")).toBe("old.malloynb");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("encodes the environment and package too, so no caller encodes again", () => {
|
|
60
|
+
expect(reportRoute("my env", "a#b", "q3.malloy")).toBe(
|
|
61
|
+
"/my%20env/a%23b/q3",
|
|
29
62
|
);
|
|
30
63
|
});
|
|
31
64
|
});
|
|
32
65
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
) => locateDocument({ kind, slug, dashboards, notebooks: withNotebooks });
|
|
47
|
-
|
|
48
|
-
it("finds a document in its own folder", () => {
|
|
49
|
-
expect(find("dashboard", "overview")).toEqual({
|
|
50
|
-
kind: "dashboard",
|
|
51
|
-
path: "dashboards/overview.malloy",
|
|
66
|
+
const REPORTS = [
|
|
67
|
+
{ path: "overview.malloy", layout: "grid" },
|
|
68
|
+
{ path: "dashboards/overview.malloy", layout: "grid" },
|
|
69
|
+
{ path: "notebooks/overview.malloy", layout: "linear" },
|
|
70
|
+
{ path: "sales/q3.malloy", layout: "linear", editable: false },
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
describe("locateReport", () => {
|
|
74
|
+
it("matches the exact path only", () => {
|
|
75
|
+
expect(locateReport("sales/q3.malloy", REPORTS)).toEqual({
|
|
76
|
+
layout: "linear",
|
|
77
|
+
path: "sales/q3.malloy",
|
|
78
|
+
editable: false,
|
|
52
79
|
});
|
|
80
|
+
expect(locateReport("q3.malloy", REPORTS)).toBeUndefined();
|
|
81
|
+
expect(locateReport("sales/q3", REPORTS)).toBeUndefined();
|
|
53
82
|
});
|
|
54
83
|
|
|
55
|
-
it("
|
|
56
|
-
expect(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
kind: "dashboard",
|
|
62
|
-
path: "notebooks/tour.malloy",
|
|
63
|
-
});
|
|
84
|
+
it("reads the layout from the listing, never the directory", () => {
|
|
85
|
+
expect(
|
|
86
|
+
locateReport("notebooks/x.malloy", [
|
|
87
|
+
{ path: "notebooks/x.malloy", layout: "grid" },
|
|
88
|
+
])?.layout,
|
|
89
|
+
).toBe("grid");
|
|
64
90
|
});
|
|
91
|
+
});
|
|
65
92
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
93
|
+
describe("resolveDrillTarget", () => {
|
|
94
|
+
it("reads a target as a package path from the root", () => {
|
|
95
|
+
const target = resolveDrillTarget("sales/q3", REPORTS);
|
|
96
|
+
expect(target.kind).toBe("path");
|
|
97
|
+
expect("report" in target && target.report.path).toBe("sales/q3.malloy");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("refuses a target that is not a plain package path: . or .. segments, empty segments, a leading /", () => {
|
|
101
|
+
for (const to of [
|
|
102
|
+
"../../x",
|
|
103
|
+
"../sales/q3",
|
|
104
|
+
"sales/../q3",
|
|
105
|
+
"./sales/q3",
|
|
106
|
+
"/sales/q3",
|
|
107
|
+
"sales//q3",
|
|
108
|
+
"sales/q3/",
|
|
109
|
+
".",
|
|
110
|
+
"..",
|
|
111
|
+
"",
|
|
112
|
+
]) {
|
|
113
|
+
expect(resolveDrillTarget(to, REPORTS)).toEqual({
|
|
114
|
+
kind: "unresolved",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("reads a bare name at the root path first, with no fallback", () => {
|
|
120
|
+
const target = resolveDrillTarget("overview", REPORTS);
|
|
121
|
+
expect(target.kind).toBe("path");
|
|
122
|
+
expect("report" in target && target.report.path).toBe("overview.malloy");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("reads a bare name as a root file only: a report elsewhere with that basename is not looked up", () => {
|
|
126
|
+
expect(resolveDrillTarget("overview", REPORTS.slice(1))).toEqual({
|
|
127
|
+
kind: "unresolved",
|
|
75
128
|
});
|
|
76
129
|
});
|
|
77
130
|
|
|
78
|
-
it("is
|
|
79
|
-
expect(
|
|
131
|
+
it("is unresolved for a path nothing is at", () => {
|
|
132
|
+
expect(resolveDrillTarget("x/q3", REPORTS)).toEqual({
|
|
133
|
+
kind: "unresolved",
|
|
134
|
+
});
|
|
80
135
|
});
|
|
81
136
|
});
|
|
137
|
+
|
|
138
|
+
/** The SDK's column of the drill case table the server's `resolveDrillDestination` shares. */
|
|
139
|
+
describe("resolveDrillTarget: the shared drill case table", () => {
|
|
140
|
+
type Answer = { kind: string; path?: string; malformed?: boolean };
|
|
141
|
+
const { cases } = JSON.parse(
|
|
142
|
+
fs.readFileSync(
|
|
143
|
+
path.resolve(
|
|
144
|
+
import.meta.dir,
|
|
145
|
+
"../ReportBuilder/testing/drillResolution.json",
|
|
146
|
+
),
|
|
147
|
+
"utf8",
|
|
148
|
+
),
|
|
149
|
+
) as {
|
|
150
|
+
cases: {
|
|
151
|
+
name: string;
|
|
152
|
+
to: string;
|
|
153
|
+
reports: { path: string; layout: string; dropped?: boolean }[];
|
|
154
|
+
server: Answer;
|
|
155
|
+
/** What the SDK answers where it differs from the server by design; `knownDifference` says why. */
|
|
156
|
+
sdk?: Answer;
|
|
157
|
+
knownDifference?: string;
|
|
158
|
+
}[];
|
|
159
|
+
};
|
|
160
|
+
for (const testCase of cases) {
|
|
161
|
+
it(testCase.name, () => {
|
|
162
|
+
// The listing: a report dropped at discovery is not in it.
|
|
163
|
+
const listed = testCase.reports.filter((r) => !r.dropped);
|
|
164
|
+
const target = resolveDrillTarget(testCase.to, listed);
|
|
165
|
+
const answer: Answer =
|
|
166
|
+
target.kind === "unresolved"
|
|
167
|
+
? { kind: target.kind }
|
|
168
|
+
: { kind: target.kind, path: target.report.path };
|
|
169
|
+
const { malformed: _malformed, ...server } = testCase.server;
|
|
170
|
+
expect(testCase.sdk === undefined).toBe(
|
|
171
|
+
testCase.knownDifference === undefined,
|
|
172
|
+
);
|
|
173
|
+
expect(answer).toEqual(testCase.sdk ?? server);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
@@ -1,55 +1,134 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A report's layout: `grid` places tiles by columns, `linear` reads top to
|
|
6
|
+
* bottom. The artifact tag decides it; where the file lives never does.
|
|
7
|
+
*/
|
|
8
|
+
export type ReportLayout = "grid" | "linear";
|
|
9
|
+
|
|
10
|
+
/** One report as the package's listing (`GET …/reports`) has it. */
|
|
11
|
+
export interface ListedReport {
|
|
12
|
+
path?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
layout?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
editable?: boolean;
|
|
17
|
+
}
|
|
6
18
|
|
|
7
19
|
export interface LocatedDocument {
|
|
8
|
-
|
|
9
|
-
/** The file within the package, wherever it lives. */
|
|
20
|
+
layout: ReportLayout;
|
|
21
|
+
/** The file within the package, wherever it lives: the report's identity. */
|
|
10
22
|
path: string;
|
|
23
|
+
/** Whether the builder opens it; false for a `.malloynb` or a `run:`-cell report. */
|
|
24
|
+
editable: boolean;
|
|
11
25
|
}
|
|
12
26
|
|
|
13
|
-
const
|
|
27
|
+
const REPORT_SUFFIX = /\.malloy(nb)?$/;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A report's display label: the basename of any path, without `.malloy` or
|
|
31
|
+
* `.malloynb`. `sales/q3.malloy` is `q3`. A label only: two reports in
|
|
32
|
+
* different directories may share it.
|
|
33
|
+
*/
|
|
34
|
+
export const documentSlug = (path: string | undefined): string | undefined => {
|
|
35
|
+
if (!path) return undefined;
|
|
36
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
37
|
+
return base.replace(REPORT_SUFFIX, "") || undefined;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** The route segment of a report's path: the path without `.malloy`, each segment encoded. A `.malloynb` keeps its suffix, since it opens by path. */
|
|
41
|
+
export const reportRoutePath = (path: string) =>
|
|
42
|
+
path
|
|
43
|
+
.replace(/\.malloy$/, "")
|
|
44
|
+
.split("/")
|
|
45
|
+
.map(encodeURIComponent)
|
|
46
|
+
.join("/");
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The Console route of a report: `/<env>/<pkg>/sales/q3` for
|
|
50
|
+
* `sales/q3.malloy`. Every segment is encoded here, the environment and
|
|
51
|
+
* package included, so no caller encodes any of them again.
|
|
52
|
+
*/
|
|
53
|
+
export const reportRoute = (
|
|
54
|
+
environmentName: string,
|
|
55
|
+
packageName: string,
|
|
56
|
+
path: string,
|
|
57
|
+
) =>
|
|
58
|
+
`/${encodeURIComponent(environmentName)}/${encodeURIComponent(packageName)}/${reportRoutePath(path)}`;
|
|
14
59
|
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The query parameter that opens a report's route in the builder:
|
|
62
|
+
* `/<env>/<pkg>/sales/q3?edit`. A parameter rather than a trailing `/edit`
|
|
63
|
+
* segment, because a segment is also a path: `sales/edit.malloy` is a report
|
|
64
|
+
* whose route is `/<env>/<pkg>/sales/edit`.
|
|
65
|
+
*/
|
|
66
|
+
export const REPORT_EDIT_PARAM = "edit";
|
|
18
67
|
|
|
19
|
-
/** The Console route
|
|
20
|
-
export const
|
|
68
|
+
/** The Console route that edits a report: its {@link reportRoute} with `?edit`. */
|
|
69
|
+
export const reportEditRoute = (
|
|
21
70
|
environmentName: string,
|
|
22
71
|
packageName: string,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
72
|
+
path: string,
|
|
73
|
+
) => `${reportRoute(environmentName, packageName, path)}?${REPORT_EDIT_PARAM}`;
|
|
74
|
+
|
|
75
|
+
/** A listed report's layout: anything but `linear` draws as a grid. */
|
|
76
|
+
export const listedLayout = (report: ListedReport): ReportLayout =>
|
|
77
|
+
report.layout === "linear" ? "linear" : "grid";
|
|
78
|
+
|
|
79
|
+
/** A listed report with a path, as a host opens it. */
|
|
80
|
+
export const locatedReport = (
|
|
81
|
+
report: ListedReport & { path: string },
|
|
82
|
+
): LocatedDocument => ({
|
|
83
|
+
layout: listedLayout(report),
|
|
84
|
+
path: report.path,
|
|
85
|
+
editable: report.editable !== false,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/** The listed report at exactly this path, or undefined. */
|
|
89
|
+
export function locateReport(
|
|
90
|
+
path: string,
|
|
91
|
+
reports: readonly ListedReport[],
|
|
92
|
+
): LocatedDocument | undefined {
|
|
93
|
+
const found = reports.find((r) => r.path === path);
|
|
94
|
+
return found?.path
|
|
95
|
+
? locatedReport({ ...found, path: found.path })
|
|
96
|
+
: undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Where a `# drill { to=… }` lands. */
|
|
100
|
+
export type DrillTarget =
|
|
101
|
+
| { kind: "path"; report: LocatedDocument }
|
|
102
|
+
| { kind: "unresolved" };
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Whether a `# drill { to=… }` is a plain package path: non-empty segments,
|
|
106
|
+
* none `.` or `..`, and no leading `/`. Anything else could name a route
|
|
107
|
+
* outside the package (`../../x`), so it resolves to nothing and a host must
|
|
108
|
+
* not build a route from it. The server's `isDrillTargetPath` is the same rule.
|
|
109
|
+
*/
|
|
110
|
+
export function isDrillTargetPath(to: string): boolean {
|
|
111
|
+
if (to === "" || to.startsWith("/")) return false;
|
|
112
|
+
return to
|
|
113
|
+
.split("/")
|
|
114
|
+
.every(
|
|
115
|
+
(segment) => segment !== "" && segment !== "." && segment !== "..",
|
|
116
|
+
);
|
|
117
|
+
}
|
|
26
118
|
|
|
27
119
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* is tried first, so a slug in both folders opens the one the link was built for.
|
|
120
|
+
* A `# drill` destination, by the server's rule (`resolveDrillDestination`):
|
|
121
|
+
* a package path from the root, with or without `.malloy` (`sales/overview`
|
|
122
|
+
* is `sales/overview.malloy`, and a bare name is a file at the root).
|
|
32
123
|
*/
|
|
33
|
-
export function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}): LocatedDocument | undefined {
|
|
44
|
-
const asDashboard = (): LocatedDocument | undefined => {
|
|
45
|
-
const found = dashboards.find((d) => d.name === slug && d.path);
|
|
46
|
-
return found?.path ? { kind: "dashboard", path: found.path } : undefined;
|
|
47
|
-
};
|
|
48
|
-
const asNotebook = (): LocatedDocument | undefined => {
|
|
49
|
-
const found = notebooks.find((n) => documentSlug(n.path) === slug);
|
|
50
|
-
return found?.path ? { kind: "notebook", path: found.path } : undefined;
|
|
51
|
-
};
|
|
52
|
-
return kind === "dashboard"
|
|
53
|
-
? (asDashboard() ?? asNotebook())
|
|
54
|
-
: (asNotebook() ?? asDashboard());
|
|
124
|
+
export function resolveDrillTarget(
|
|
125
|
+
to: string,
|
|
126
|
+
reports: readonly ListedReport[],
|
|
127
|
+
): DrillTarget {
|
|
128
|
+
if (!isDrillTargetPath(to)) return { kind: "unresolved" };
|
|
129
|
+
for (const candidate of [`${to}.malloy`, to]) {
|
|
130
|
+
const report = locateReport(candidate, reports);
|
|
131
|
+
if (report) return { kind: "path", report };
|
|
132
|
+
}
|
|
133
|
+
return { kind: "unresolved" };
|
|
55
134
|
}
|
|
@@ -3,12 +3,21 @@
|
|
|
3
3
|
|
|
4
4
|
export { default as Package, type OpenDocumentRequest } from "./Package";
|
|
5
5
|
export {
|
|
6
|
-
documentRoute,
|
|
7
6
|
documentSlug,
|
|
8
|
-
|
|
7
|
+
isDrillTargetPath,
|
|
8
|
+
locateReport,
|
|
9
|
+
REPORT_EDIT_PARAM,
|
|
10
|
+
reportEditRoute,
|
|
11
|
+
reportRoute,
|
|
12
|
+
reportRoutePath,
|
|
13
|
+
resolveDrillTarget,
|
|
14
|
+
type DrillTarget,
|
|
15
|
+
type ListedReport,
|
|
9
16
|
type LocatedDocument,
|
|
17
|
+
type ReportLayout,
|
|
10
18
|
} from "./documentLocation";
|
|
11
|
-
export { useDocumentLocation } from "./useDocumentLocation";
|
|
19
|
+
export { useDocumentLocation, useReportListing } from "./useDocumentLocation";
|
|
20
|
+
export { useDraftLayout } from "./useDraftLayout";
|
|
12
21
|
export {
|
|
13
22
|
NewDocumentDialog,
|
|
14
23
|
type NewDocumentDialogProps,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { legacyReportQueryKeys } from "../legacy/queryKeys";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Drop every cached read of a package's reports after a write changed them:
|
|
9
|
+
* each report's manifest, the listing, and the deprecated readers' copies,
|
|
10
|
+
* whose listings a layout switch moves a report between. With `modelPath`,
|
|
11
|
+
* the one report's own cached reads too.
|
|
12
|
+
*/
|
|
13
|
+
export function invalidateReportQueries(
|
|
14
|
+
queryClient: QueryClient,
|
|
15
|
+
environmentName: string,
|
|
16
|
+
packageName: string,
|
|
17
|
+
modelPath?: string,
|
|
18
|
+
): void {
|
|
19
|
+
for (const queryKey of [
|
|
20
|
+
["report"],
|
|
21
|
+
["reports"],
|
|
22
|
+
...legacyReportQueryKeys(environmentName, packageName, modelPath),
|
|
23
|
+
])
|
|
24
|
+
void queryClient.invalidateQueries({ queryKey });
|
|
25
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import type { ApiClients } from "../ServerProvider";
|
|
6
|
+
import { fetchReportListing } from "./useDocumentLocation";
|
|
7
|
+
|
|
8
|
+
const clientsAnswering = (answer: () => Promise<unknown>) =>
|
|
9
|
+
({ reports: { listReports: answer } }) as unknown as ApiClients;
|
|
10
|
+
|
|
11
|
+
describe("fetchReportListing", () => {
|
|
12
|
+
it("returns the listing", async () => {
|
|
13
|
+
const reports = [{ path: "a.malloy", layout: "grid" }];
|
|
14
|
+
expect(
|
|
15
|
+
await fetchReportListing(
|
|
16
|
+
clientsAnswering(async () => ({ data: reports })),
|
|
17
|
+
"env",
|
|
18
|
+
"pkg",
|
|
19
|
+
),
|
|
20
|
+
).toEqual(reports as never);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("reads a 404 as an older server with no reports to list", async () => {
|
|
24
|
+
expect(
|
|
25
|
+
await fetchReportListing(
|
|
26
|
+
clientsAnswering(() =>
|
|
27
|
+
Promise.reject({ response: { status: 404 } }),
|
|
28
|
+
),
|
|
29
|
+
"env",
|
|
30
|
+
"pkg",
|
|
31
|
+
),
|
|
32
|
+
).toEqual([]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("raises a failure with no answer, rather than reading it as no reports", async () => {
|
|
36
|
+
// Every reader caches this listing; an empty one cached for a minute
|
|
37
|
+
// would say "nothing here" about a package that has reports.
|
|
38
|
+
await expect(
|
|
39
|
+
fetchReportListing(
|
|
40
|
+
clientsAnswering(() => Promise.reject(new Error("Network Error"))),
|
|
41
|
+
"env",
|
|
42
|
+
"pkg",
|
|
43
|
+
),
|
|
44
|
+
).rejects.toThrow("Network Error");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("raises a server error", async () => {
|
|
48
|
+
await expect(
|
|
49
|
+
fetchReportListing(
|
|
50
|
+
clientsAnswering(() =>
|
|
51
|
+
Promise.reject({ response: { status: 500 } }),
|
|
52
|
+
),
|
|
53
|
+
"env",
|
|
54
|
+
"pkg",
|
|
55
|
+
),
|
|
56
|
+
).rejects.toEqual({ response: { status: 500 } });
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -2,58 +2,116 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
5
|
-
import { useServer } from "../ServerProvider";
|
|
5
|
+
import { useServer, type ApiClients } from "../ServerProvider";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
type
|
|
7
|
+
locateReport,
|
|
8
|
+
type ListedReport,
|
|
9
9
|
type LocatedDocument,
|
|
10
10
|
} from "./documentLocation";
|
|
11
11
|
|
|
12
|
+
/** The query key of a package's report listing, so every reader shares one request and one invalidation. */
|
|
13
|
+
const reportsQueryKey = (
|
|
14
|
+
environmentName: string,
|
|
15
|
+
packageName: string,
|
|
16
|
+
versionId?: string,
|
|
17
|
+
) => ["reports", environmentName, packageName, versionId];
|
|
18
|
+
|
|
12
19
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
20
|
+
* `GET …/reports`, as the array every reader of {@link reportsQueryKey} caches.
|
|
21
|
+
* An older server with no such route (404) is a package with no reports to
|
|
22
|
+
* list rather than an error. Anything else, including no answer at all, is
|
|
23
|
+
* raised: every reader caches this listing, and an empty one standing in for
|
|
24
|
+
* a failure would say "nothing here" about a package that has reports.
|
|
18
25
|
*/
|
|
19
|
-
export function
|
|
26
|
+
export async function fetchReportListing(
|
|
27
|
+
apiClients: ApiClients,
|
|
20
28
|
environmentName: string,
|
|
21
29
|
packageName: string,
|
|
22
|
-
kind: DocumentKind,
|
|
23
|
-
slug: string,
|
|
24
30
|
versionId?: string,
|
|
25
|
-
):
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
queryFn: () =>
|
|
30
|
-
apiClients.dashboards.listDashboards(
|
|
31
|
+
): Promise<ListedReport[]> {
|
|
32
|
+
try {
|
|
33
|
+
return (
|
|
34
|
+
await apiClients.reports.listReports(
|
|
31
35
|
environmentName,
|
|
32
36
|
packageName,
|
|
33
37
|
versionId,
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
)
|
|
39
|
+
).data;
|
|
40
|
+
} catch (e) {
|
|
41
|
+
const status = (e as { response?: { status?: number } })?.response
|
|
42
|
+
?.status;
|
|
43
|
+
if (status === 404) return [];
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The package's reports, from `GET …/reports`: one listing for both layouts.
|
|
50
|
+
*
|
|
51
|
+
* `settled` is false until it has answered. An older server with no such
|
|
52
|
+
* route answers 404, which reads as a package with no reports rather than an
|
|
53
|
+
* error, so a host still renders. Any other failure is `isError`, with
|
|
54
|
+
* `refetch` to try again: a caller shows it rather than an empty listing.
|
|
55
|
+
* `isFetching` is true while a request is in flight, including the refetch
|
|
56
|
+
* that follows a write's invalidation, when the cached `reports` predate it.
|
|
57
|
+
*/
|
|
58
|
+
export function useReportListing(
|
|
59
|
+
environmentName: string,
|
|
60
|
+
packageName: string,
|
|
61
|
+
versionId?: string,
|
|
62
|
+
enabled = true,
|
|
63
|
+
) {
|
|
64
|
+
const { apiClients } = useServer();
|
|
65
|
+
const query = useQueryWithApiError({
|
|
66
|
+
queryKey: reportsQueryKey(environmentName, packageName, versionId),
|
|
38
67
|
queryFn: () =>
|
|
39
|
-
|
|
68
|
+
fetchReportListing(
|
|
69
|
+
apiClients,
|
|
40
70
|
environmentName,
|
|
41
71
|
packageName,
|
|
42
72
|
versionId,
|
|
43
73
|
),
|
|
74
|
+
enabled,
|
|
75
|
+
// One request per page however many readers mount: the route, the
|
|
76
|
+
// header's Edit button, drill and the builder all read this listing, and
|
|
77
|
+
// a save invalidates it.
|
|
78
|
+
staleTime: 60_000,
|
|
44
79
|
});
|
|
45
|
-
|
|
46
|
-
(query
|
|
80
|
+
return {
|
|
81
|
+
reports: (query.data ?? []) as ListedReport[],
|
|
82
|
+
settled: query.isSuccess || query.isError,
|
|
83
|
+
isFetching: query.isFetching,
|
|
84
|
+
isError: query.isError,
|
|
85
|
+
error: query.error,
|
|
86
|
+
refetch: query.refetch,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The report at a package path, from the package's listing, matched exactly.
|
|
92
|
+
*
|
|
93
|
+
* `settled` is false until the listing has answered; a path the listing does
|
|
94
|
+
* not have (a draft, a model, or an older server) has a `location` of
|
|
95
|
+
* undefined, and the caller decides what that path is instead.
|
|
96
|
+
*/
|
|
97
|
+
export function useDocumentLocation(
|
|
98
|
+
environmentName: string,
|
|
99
|
+
packageName: string,
|
|
100
|
+
path: string,
|
|
101
|
+
versionId?: string,
|
|
102
|
+
): {
|
|
103
|
+
location: LocatedDocument | undefined;
|
|
104
|
+
settled: boolean;
|
|
105
|
+
reports: readonly ListedReport[];
|
|
106
|
+
} {
|
|
107
|
+
const { reports, settled } = useReportListing(
|
|
108
|
+
environmentName,
|
|
109
|
+
packageName,
|
|
110
|
+
versionId,
|
|
47
111
|
);
|
|
48
112
|
return {
|
|
49
113
|
settled,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
kind,
|
|
53
|
-
slug,
|
|
54
|
-
dashboards: dashboards.data?.data ?? [],
|
|
55
|
-
notebooks: notebooks.data?.data ?? [],
|
|
56
|
-
})
|
|
57
|
-
: undefined,
|
|
114
|
+
reports,
|
|
115
|
+
location: settled ? locateReport(path, reports) : undefined,
|
|
58
116
|
};
|
|
59
117
|
}
|