@malloy-publisher/sdk 0.9.6 → 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-BUb2Xvr2.es.js → RenderedResult-DZj-FnOJ.es.js} +2 -2
- package/dist/{ServerProvider-C6QQVKPm.es.js → ServerProvider-B_bPAsu2.es.js} +595 -410
- 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 +489 -111
- 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-0sxonf6N.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 +6 -4
- 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
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { saveTarget } from "../DashboardBuilder/documentSession";
|
|
4
|
+
import { saveTarget } from "../ReportBuilder/documentSession";
|
|
6
5
|
import {
|
|
7
6
|
isDocumentNotFound,
|
|
8
7
|
type DocumentLocator,
|
|
9
8
|
type DocumentStorage,
|
|
10
|
-
type DocumentType,
|
|
11
9
|
type Workspace,
|
|
12
10
|
} from "../DocumentStorage/DocumentStorage";
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
11
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
12
|
+
import {
|
|
13
|
+
locatorFor,
|
|
14
|
+
normalizeDirectory,
|
|
15
|
+
reportPathForTitle,
|
|
16
|
+
} from "./documentPath";
|
|
17
|
+
import { reportEmitter, type ReportEventHandler } from "../Report/telemetry";
|
|
18
|
+
import { now } from "../../utils/clock";
|
|
15
19
|
import { newDocumentProblem, type NewDocument } from "./guards";
|
|
16
|
-
import {
|
|
20
|
+
import { newReportSource } from "./newNotebook";
|
|
17
21
|
|
|
18
22
|
/** How many names are tried before a create gives up: `title`, `title-2`, ... */
|
|
19
23
|
export const MAX_SLUG_ATTEMPTS = 20;
|
|
@@ -54,29 +58,63 @@ export type CreateTarget =
|
|
|
54
58
|
};
|
|
55
59
|
|
|
56
60
|
export interface CreatedDocument {
|
|
57
|
-
|
|
58
|
-
/**
|
|
61
|
+
layout: ReportLayout;
|
|
62
|
+
/**
|
|
63
|
+
* Package-relative, e.g. `sales.malloy`: the report's identity. At the
|
|
64
|
+
* package root unless a `directory` or `path` was given. On the storage
|
|
65
|
+
* route this is where the store says the file lands
|
|
66
|
+
* ({@link DocumentStorage.resolveDocumentPath}), which may differ from the
|
|
67
|
+
* path asked for.
|
|
68
|
+
*/
|
|
59
69
|
path: string;
|
|
60
|
-
/** `sales` for `
|
|
70
|
+
/** `sales` for `sales.malloy` or `team/sales.malloy`: a display label. */
|
|
61
71
|
slug: string;
|
|
62
72
|
/** Set on the storage route: the new document's address there. */
|
|
63
73
|
locator?: DocumentLocator;
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
export interface CreateDocumentOptions {
|
|
67
|
-
|
|
77
|
+
/** The report's layout. Default linear. */
|
|
78
|
+
layout?: ReportLayout;
|
|
79
|
+
/**
|
|
80
|
+
* Exactly where to write it, package-relative with `.malloy`. A path that is
|
|
81
|
+
* taken is refused rather than renamed. Absent, the title's slug is used at
|
|
82
|
+
* the package root (or in `directory`), with `-2`, `-3`… when taken.
|
|
83
|
+
*/
|
|
84
|
+
path?: string;
|
|
85
|
+
/** The directory a title-named file goes in; default the package root. */
|
|
86
|
+
directory?: string;
|
|
68
87
|
document: NewDocument;
|
|
69
88
|
target: CreateTarget;
|
|
70
89
|
onCreated?: (created: CreatedDocument) => void;
|
|
71
|
-
|
|
90
|
+
/** `report.created` with where it landed, or `report.create_refused` with why not. */
|
|
91
|
+
onEvent?: ReportEventHandler;
|
|
72
92
|
}
|
|
73
93
|
|
|
74
94
|
const slugOf = (path: string) =>
|
|
75
|
-
path.slice(path.
|
|
95
|
+
path.slice(path.lastIndexOf("/") + 1).replace(/\.malloy$/, "");
|
|
96
|
+
|
|
97
|
+
/** Why `path` cannot be where a new report is written, or undefined when it can. */
|
|
98
|
+
export function reportPathProblem(path: string): string | undefined {
|
|
99
|
+
if (!path.endsWith(".malloy"))
|
|
100
|
+
return "A report's file name ends in .malloy.";
|
|
101
|
+
const segments = path.split("/");
|
|
102
|
+
if (segments.some((s) => s === "" || s === "." || s === ".."))
|
|
103
|
+
return "A location is a path inside the package, such as sales/q3.malloy.";
|
|
104
|
+
if (segments.at(-1) === ".malloy") return "A report's file needs a name.";
|
|
105
|
+
// Without case: on a case-insensitive file system `Public/` is `public/`.
|
|
106
|
+
if (segments[0].toLowerCase() === "public")
|
|
107
|
+
return "A report cannot live under public/, which is served as plain files.";
|
|
108
|
+
// Without case too: on a case-insensitive file system it is the surface.
|
|
109
|
+
if (path.toLowerCase() === "index.malloy")
|
|
110
|
+
return "The package's index.malloy is its surface, never a report.";
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
76
113
|
|
|
77
114
|
/**
|
|
78
|
-
* Write a new
|
|
79
|
-
*
|
|
115
|
+
* Write a new report, never over an existing file, and say where it went: at
|
|
116
|
+
* the package root unless the caller names a directory or a path. Reads
|
|
117
|
+
* nothing back: the host navigates from what this returns.
|
|
80
118
|
*
|
|
81
119
|
* On the storage route the listing alone cannot be trusted to be current, and
|
|
82
120
|
* `saveDocument` replaces what is there, so each candidate name is read first
|
|
@@ -85,75 +123,117 @@ const slugOf = (path: string) =>
|
|
|
85
123
|
export async function createDocument(
|
|
86
124
|
options: CreateDocumentOptions,
|
|
87
125
|
): Promise<CreatedDocument> {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
126
|
+
const layout: ReportLayout = options.layout ?? "linear";
|
|
127
|
+
const startedAt = now();
|
|
128
|
+
let created: CreatedDocument;
|
|
129
|
+
try {
|
|
130
|
+
created = await writeNewReport(options, layout);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
reportEmitter({ path: options.path ?? "", layout }, options.onEvent).emit(
|
|
133
|
+
{
|
|
134
|
+
type: "report.create_refused",
|
|
135
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
reportEmitter({ path: created.path, layout }, options.onEvent).emit({
|
|
141
|
+
type: "report.created",
|
|
142
|
+
where: options.target.route === "package" ? "package" : "host",
|
|
143
|
+
durationMs: now() - startedAt,
|
|
144
|
+
});
|
|
145
|
+
options.onCreated?.(created);
|
|
146
|
+
return created;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function writeNewReport(
|
|
150
|
+
options: CreateDocumentOptions,
|
|
151
|
+
layout: ReportLayout,
|
|
152
|
+
): Promise<CreatedDocument> {
|
|
153
|
+
const { document, target } = options;
|
|
154
|
+
const problem = newDocumentProblem(document);
|
|
90
155
|
if (problem) throw new Error(problem);
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
156
|
+
const directory = normalizeDirectory(options.directory);
|
|
157
|
+
// The one path asked for, or the title's slug and its numbered variants. Taken is by path, and only by path.
|
|
158
|
+
const candidates =
|
|
159
|
+
options.path !== undefined
|
|
160
|
+
? [options.path]
|
|
161
|
+
: Array.from({ length: MAX_SLUG_ATTEMPTS }, (_, i) =>
|
|
162
|
+
reportPathForTitle(document.title, i + 1, directory),
|
|
163
|
+
);
|
|
164
|
+
// Every computed path is checked, not only a `path` given outright: a
|
|
165
|
+
// `directory` of `../x` or `public` is refused here, before the package
|
|
166
|
+
// or the store is asked anything.
|
|
167
|
+
for (const candidate of candidates) {
|
|
168
|
+
const pathProblem = reportPathProblem(candidate);
|
|
169
|
+
if (pathProblem) throw new Error(pathProblem);
|
|
170
|
+
}
|
|
171
|
+
// The import is relative to where the report lands, so each candidate gets its own text.
|
|
172
|
+
const sourceAt = (path: string) => newReportSource(document, layout, path);
|
|
95
173
|
|
|
96
|
-
let created: CreatedDocument;
|
|
97
174
|
if (target.route === "package") {
|
|
98
175
|
const taken = new Set(target.existing);
|
|
99
176
|
let path: string | undefined;
|
|
100
|
-
for (
|
|
101
|
-
const candidate = documentPathForTitle(kind, document.title, n);
|
|
177
|
+
for (const candidate of candidates) {
|
|
102
178
|
if (taken.has(candidate)) continue;
|
|
103
179
|
try {
|
|
104
|
-
await target.write(candidate,
|
|
180
|
+
await target.write(candidate, sourceAt(candidate));
|
|
105
181
|
path = candidate;
|
|
182
|
+
break;
|
|
106
183
|
} catch (error) {
|
|
107
184
|
// A create-only write refused as a conflict means the listing was stale; the next name is free to try.
|
|
108
185
|
if (!isConflict(error)) throw error;
|
|
109
186
|
}
|
|
110
187
|
}
|
|
111
|
-
if (path === undefined) throw noFreeName(document.title);
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
188
|
+
if (path === undefined) throw noFreeName(document.title, options.path);
|
|
189
|
+
return { layout, path, slug: slugOf(path) };
|
|
190
|
+
}
|
|
191
|
+
const { storage, workspace, environmentName, packageName } = target;
|
|
192
|
+
const inPackage = new Set(target.existing);
|
|
193
|
+
const listed = new Set(
|
|
194
|
+
(await storage.listDocuments(workspace)).map((l) => l.path),
|
|
195
|
+
);
|
|
196
|
+
let found: CreatedDocument | undefined;
|
|
197
|
+
for (const requested of candidates) {
|
|
198
|
+
const locator = locatorFor(
|
|
199
|
+
layout,
|
|
200
|
+
workspace.name,
|
|
201
|
+
environmentName,
|
|
202
|
+
packageName,
|
|
203
|
+
requested,
|
|
118
204
|
);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (!present) found = { kind, path, slug: slugOf(path), locator };
|
|
205
|
+
// Where the file really lands: the text is rendered for that path, so its imports resolve there.
|
|
206
|
+
const path = (await storage.resolveDocumentPath?.(locator)) ?? requested;
|
|
207
|
+
if (
|
|
208
|
+
listed.has(locator.path) ||
|
|
209
|
+
inPackage.has(requested) ||
|
|
210
|
+
inPackage.has(path)
|
|
211
|
+
)
|
|
212
|
+
continue;
|
|
213
|
+
let present = true;
|
|
214
|
+
try {
|
|
215
|
+
await storage.getDocument(locator);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
// Only absence frees the name; a backend that could not answer says nothing about it.
|
|
218
|
+
if (!isDocumentNotFound(error)) throw error;
|
|
219
|
+
present = false;
|
|
220
|
+
}
|
|
221
|
+
if (!present) {
|
|
222
|
+
found = { layout, path, slug: slugOf(path), locator };
|
|
223
|
+
break;
|
|
139
224
|
}
|
|
140
|
-
if (found === undefined) throw noFreeName(document.title);
|
|
141
|
-
await storage.saveDocument(found.locator!, source);
|
|
142
|
-
created = found;
|
|
143
225
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
where: target.route === "package" ? "package" : "host",
|
|
148
|
-
});
|
|
149
|
-
onCreated?.(created);
|
|
150
|
-
return created;
|
|
226
|
+
if (found === undefined) throw noFreeName(document.title, options.path);
|
|
227
|
+
await storage.saveDocument(found.locator!, sourceAt(found.path));
|
|
228
|
+
return found;
|
|
151
229
|
}
|
|
152
230
|
|
|
153
231
|
const isConflict = (error: unknown) =>
|
|
154
232
|
(error as { response?: { status?: number } })?.response?.status === 409;
|
|
155
233
|
|
|
156
|
-
const noFreeName = (title: string) =>
|
|
234
|
+
const noFreeName = (title: string, path?: string) =>
|
|
157
235
|
new Error(
|
|
158
|
-
|
|
236
|
+
path !== undefined
|
|
237
|
+
? `${path} already exists. Fix: choose a different location.`
|
|
238
|
+
: `No free file name for "${title}" after ${MAX_SLUG_ATTEMPTS} tries. Fix: choose a different title.`,
|
|
159
239
|
);
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { slugFor } from "../
|
|
4
|
+
import { slugFor } from "../ReportBuilder/newDashboard";
|
|
5
5
|
import type { DocumentLocator, DocumentType } from "../DocumentStorage";
|
|
6
6
|
|
|
7
|
-
export { newDashboardSource, slugFor } from "../
|
|
7
|
+
export { newDashboardSource, slugFor } from "../ReportBuilder/newDashboard";
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
/**
|
|
10
|
+
* A directory as the create dialog takes it: no leading or trailing slash,
|
|
11
|
+
* `""` for the package root.
|
|
12
|
+
*/
|
|
13
|
+
export const normalizeDirectory = (directory: string | undefined) =>
|
|
14
|
+
// Split rather than trim with `^\/+|\/+$`, which backtracks polynomially on a run of slashes.
|
|
15
|
+
(directory ?? "")
|
|
16
|
+
.trim()
|
|
17
|
+
.replace(/\\/g, "/")
|
|
18
|
+
.split("/")
|
|
19
|
+
.filter((segment) => segment !== "")
|
|
20
|
+
.join("/");
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The package-relative file for a slug: `<slug>.malloy` at the package root,
|
|
24
|
+
* or under `directory` when the author typed one. No directory is chosen for
|
|
25
|
+
* a report by its layout.
|
|
26
|
+
*/
|
|
27
|
+
export function reportPathFor(slug: string, directory?: string): string {
|
|
28
|
+
const dir = normalizeDirectory(directory);
|
|
29
|
+
return `${dir === "" ? "" : `${dir}/`}${slug}.malloy`;
|
|
12
30
|
}
|
|
13
31
|
|
|
14
32
|
/** A title's slug, with a stand-in for a title that has no letters or digits. */
|
|
@@ -17,24 +35,35 @@ export function slugOrFallback(title: string): string {
|
|
|
17
35
|
}
|
|
18
36
|
|
|
19
37
|
/** The file for a title; `suffix` 1 is the bare slug, 2 and up append `-N`. */
|
|
20
|
-
export function
|
|
21
|
-
kind: DocumentType,
|
|
38
|
+
export function reportPathForTitle(
|
|
22
39
|
title: string,
|
|
23
40
|
suffix = 1,
|
|
41
|
+
directory?: string,
|
|
24
42
|
): string {
|
|
25
43
|
const slug = slugOrFallback(title);
|
|
26
|
-
return
|
|
44
|
+
return reportPathFor(suffix > 1 ? `${slug}-${suffix}` : slug, directory);
|
|
27
45
|
}
|
|
28
46
|
|
|
29
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* A report's identity in a host's store: `<environment>/<package>/<path>`.
|
|
49
|
+
* Every reader and writer of a store mints it here, and `draftKey(env, pkg,
|
|
50
|
+
* "")` is the prefix every report of one package shares.
|
|
51
|
+
*/
|
|
52
|
+
export const draftKey = (
|
|
53
|
+
environmentName: string,
|
|
54
|
+
packageName: string,
|
|
55
|
+
path: string,
|
|
56
|
+
) => `${environmentName}/${packageName}/${path}`;
|
|
57
|
+
|
|
58
|
+
/** A report's address in a store, its {@link draftKey}, with the layout a save records. */
|
|
30
59
|
export const locatorFor = (
|
|
31
|
-
|
|
60
|
+
layout: DocumentType,
|
|
32
61
|
workspace: string,
|
|
33
62
|
environmentName: string,
|
|
34
63
|
packageName: string,
|
|
35
64
|
path: string,
|
|
36
65
|
): DocumentLocator => ({
|
|
37
66
|
workspace,
|
|
38
|
-
type:
|
|
39
|
-
path:
|
|
67
|
+
type: layout,
|
|
68
|
+
path: draftKey(environmentName, packageName, path),
|
|
40
69
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
-
import { annotationTextProblem } from "../
|
|
4
|
+
import { annotationTextProblem } from "../ReportBuilder/annotationText";
|
|
5
5
|
import { isBareName } from "../../utils/malloyText";
|
|
6
|
-
import type { DocumentType } from "../DocumentStorage";
|
|
7
6
|
|
|
8
7
|
export const malloyName = (name: string) =>
|
|
9
8
|
isBareName(name) ? name : `\`${name}\``;
|
|
@@ -17,29 +16,22 @@ export interface NewDocument {
|
|
|
17
16
|
view: string;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
/** Why `input` cannot be written into a new
|
|
21
|
-
export function newDocumentProblem(
|
|
22
|
-
kind: DocumentType,
|
|
23
|
-
input: NewDocument,
|
|
24
|
-
): string | undefined {
|
|
19
|
+
/** Why `input` cannot be written into a new report, of either layout, or undefined when it can. */
|
|
20
|
+
export function newDocumentProblem(input: NewDocument): string | undefined {
|
|
25
21
|
const { title, modelPath, source, view } = input;
|
|
26
22
|
if (title.trim() === "") return "A title cannot be empty.";
|
|
27
23
|
const textProblem = annotationTextProblem("title", title);
|
|
28
24
|
if (textProblem) return textProblem;
|
|
29
|
-
if (
|
|
30
|
-
return "A title cannot contain `|##`, which closes
|
|
25
|
+
if (title.includes("|##"))
|
|
26
|
+
return "A title cannot contain `|##`, which closes the report's artifact tag.";
|
|
31
27
|
if (/["\\\r\n]/.test(modelPath) || modelPath.trim() === "")
|
|
32
28
|
return `The model path ${JSON.stringify(modelPath)} cannot be written as an import.`;
|
|
33
|
-
//
|
|
29
|
+
// Both layouts back-quote a name that is not an identifier.
|
|
34
30
|
for (const [what, name] of [
|
|
35
31
|
["source", source],
|
|
36
32
|
["view", view],
|
|
37
33
|
] as const)
|
|
38
|
-
if (
|
|
39
|
-
name.trim() === "" ||
|
|
40
|
-
/[`\r\n\\]/.test(name) ||
|
|
41
|
-
(kind === "dashboard" && !isBareName(name))
|
|
42
|
-
)
|
|
34
|
+
if (name.trim() === "" || /[`\r\n\\]/.test(name))
|
|
43
35
|
return `The ${what} name ${JSON.stringify(name)} cannot be written as a Malloy name.`;
|
|
44
36
|
return undefined;
|
|
45
37
|
}
|
|
@@ -5,23 +5,19 @@ export {
|
|
|
5
5
|
createDocument,
|
|
6
6
|
createRoute,
|
|
7
7
|
MAX_SLUG_ATTEMPTS,
|
|
8
|
+
reportPathProblem,
|
|
8
9
|
type CreatedDocument,
|
|
9
10
|
type CreateDocumentOptions,
|
|
10
11
|
type CreateTarget,
|
|
11
12
|
} from "./createDocument";
|
|
12
13
|
export {
|
|
13
|
-
documentPathFor,
|
|
14
|
-
documentPathForTitle,
|
|
15
14
|
locatorFor,
|
|
16
15
|
newDashboardSource,
|
|
16
|
+
reportPathFor,
|
|
17
|
+
reportPathForTitle,
|
|
17
18
|
slugFor,
|
|
18
19
|
slugOrFallback,
|
|
19
20
|
} from "./documentPath";
|
|
20
|
-
export type {
|
|
21
|
-
DashboardCreatedEvent,
|
|
22
|
-
DocumentCreatedEvent,
|
|
23
|
-
NotebookCreatedEvent,
|
|
24
|
-
} from "./events";
|
|
25
21
|
export { newDocumentProblem, type NewDocument } from "./guards";
|
|
26
22
|
export { newNotebookSource } from "./newNotebook";
|
|
27
23
|
export { useDocumentChoices, type DocumentChoice } from "./useDocumentChoices";
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
import { describe, expect, it } from "bun:test";
|
|
5
5
|
import { lintNotebookText } from "../../../../server/src/service/notebook_lint";
|
|
6
|
-
import { isQueryTile, isTextTile } from "../
|
|
6
|
+
import { isQueryTile, isTextTile } from "../ReportBuilder/document";
|
|
7
7
|
import {
|
|
8
8
|
readDashboardDocument,
|
|
9
9
|
readFailed,
|
|
10
|
-
} from "../
|
|
11
|
-
import {
|
|
10
|
+
} from "../ReportBuilder/readDocument";
|
|
11
|
+
import { reportPathFor, reportPathForTitle, slugFor } from "./documentPath";
|
|
12
12
|
import { newDocumentProblem } from "./guards";
|
|
13
|
-
import { newNotebookSource } from "./newNotebook";
|
|
13
|
+
import { newNotebookSource, newReportSource } from "./newNotebook";
|
|
14
14
|
|
|
15
15
|
const INPUT = {
|
|
16
16
|
title: 'Sales "West"',
|
|
@@ -40,7 +40,7 @@ describe("newNotebookSource", () => {
|
|
|
40
40
|
const result = await readDashboardDocument(text);
|
|
41
41
|
if (readFailed(result)) throw new Error(result.reason);
|
|
42
42
|
const { document } = result;
|
|
43
|
-
expect(document.
|
|
43
|
+
expect(document.layout).toBe("linear");
|
|
44
44
|
expect(
|
|
45
45
|
document.tiles.map((t) => (isTextTile(t) ? "text" : "query")),
|
|
46
46
|
).toEqual(["text", "query"]);
|
|
@@ -54,7 +54,7 @@ describe("newNotebookSource", () => {
|
|
|
54
54
|
|
|
55
55
|
it("writes the artifact tag as a block with a tile on each line, named for its view", () => {
|
|
56
56
|
expect(newNotebookSource(INPUT)).toContain(
|
|
57
|
-
'##| artifact {
|
|
57
|
+
'##| artifact { layout=linear title="Sales \\"West\\""\n tiles=[\n intro { kind=text },\n "order_items_tiles -> by_category_tile"\n ]\n}\n|##\n',
|
|
58
58
|
);
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -66,10 +66,19 @@ describe("newNotebookSource", () => {
|
|
|
66
66
|
expect(result.document.tiles.filter(isQueryTile)).toHaveLength(1);
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
it("imports the one source by name", () => {
|
|
69
|
+
it("imports the one source by name, relative to the package root by default", () => {
|
|
70
70
|
expect(newNotebookSource(INPUT)).toContain(
|
|
71
|
+
'import { order_items } from "models/storefront.malloy"',
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("imports relative to where the report is written", () => {
|
|
76
|
+
expect(newNotebookSource(INPUT, "team/sales.malloy")).toContain(
|
|
71
77
|
'import { order_items } from "../models/storefront.malloy"',
|
|
72
78
|
);
|
|
79
|
+
expect(newNotebookSource(INPUT, "models/sales.malloy")).toContain(
|
|
80
|
+
'import { order_items } from "storefront.malloy"',
|
|
81
|
+
);
|
|
73
82
|
});
|
|
74
83
|
|
|
75
84
|
it("throws on what the guard refuses", () => {
|
|
@@ -78,17 +87,71 @@ describe("newNotebookSource", () => {
|
|
|
78
87
|
});
|
|
79
88
|
});
|
|
80
89
|
|
|
81
|
-
describe("
|
|
82
|
-
it("
|
|
90
|
+
describe("newReportSource", () => {
|
|
91
|
+
it("writes the two layouts from one template, differing only in layout= and the grid tag", () => {
|
|
92
|
+
const grid = newReportSource(INPUT, "grid").split("\n");
|
|
93
|
+
const linear = newReportSource(INPUT, "linear").split("\n");
|
|
94
|
+
expect(grid).toHaveLength(linear.length);
|
|
95
|
+
const differ = grid
|
|
96
|
+
.map((line, i) => [line, linear[i]])
|
|
97
|
+
.filter(([a, b]) => a !== b);
|
|
98
|
+
expect(differ).toEqual([
|
|
99
|
+
[
|
|
100
|
+
'##| artifact { layout=grid title="Sales \\"West\\""',
|
|
101
|
+
'##| artifact { layout=linear title="Sales \\"West\\""',
|
|
102
|
+
],
|
|
103
|
+
["} dashboard { columns=12 }", "}"],
|
|
104
|
+
]);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("never writes kind= for the layout", () => {
|
|
108
|
+
for (const layout of ["grid", "linear"] as const)
|
|
109
|
+
expect(newReportSource(INPUT, layout)).not.toMatch(
|
|
110
|
+
/kind=(dashboard|notebook)/,
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("reads back by its tag: grid as a dashboard, linear as a notebook", async () => {
|
|
115
|
+
const grid = await readDashboardDocument(newReportSource(INPUT, "grid"));
|
|
116
|
+
if (readFailed(grid)) throw new Error(grid.reason);
|
|
117
|
+
expect(grid.document.layout).toBe("grid");
|
|
118
|
+
expect(grid.document.columns).toBe(12);
|
|
83
119
|
expect(
|
|
84
|
-
|
|
85
|
-
).
|
|
120
|
+
grid.document.tiles.map((t) => (isTextTile(t) ? "text" : "query")),
|
|
121
|
+
).toEqual(["text", "query"]);
|
|
122
|
+
const linear = await readDashboardDocument(
|
|
123
|
+
newReportSource(INPUT, "linear"),
|
|
124
|
+
);
|
|
125
|
+
if (readFailed(linear)) throw new Error(linear.reason);
|
|
126
|
+
expect(linear.document.layout).toBe("linear");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("reads the same wherever the file would sit", async () => {
|
|
130
|
+
for (const path of ["dashboards/x.malloy", "notebooks/x.malloy"]) {
|
|
131
|
+
const grid = await readDashboardDocument(
|
|
132
|
+
newReportSource(INPUT, "grid"),
|
|
133
|
+
path,
|
|
134
|
+
);
|
|
135
|
+
if (readFailed(grid)) throw new Error(grid.reason);
|
|
136
|
+
expect(grid.document.layout).toBe("grid");
|
|
137
|
+
const linear = await readDashboardDocument(
|
|
138
|
+
newReportSource(INPUT, "linear"),
|
|
139
|
+
path,
|
|
140
|
+
);
|
|
141
|
+
if (readFailed(linear)) throw new Error(linear.reason);
|
|
142
|
+
expect(linear.document.layout).toBe("linear");
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe("newDocumentProblem", () => {
|
|
148
|
+
it("takes a name either layout back-quotes", () => {
|
|
86
149
|
expect(
|
|
87
|
-
newDocumentProblem(
|
|
150
|
+
newDocumentProblem({ ...INPUT, source: "order items" }),
|
|
88
151
|
).toBeUndefined();
|
|
89
152
|
});
|
|
90
153
|
|
|
91
|
-
it("back-quotes a source named like a keyword
|
|
154
|
+
it("back-quotes a source named like a keyword", () => {
|
|
92
155
|
const text = newNotebookSource({
|
|
93
156
|
...INPUT,
|
|
94
157
|
source: "source",
|
|
@@ -97,9 +160,7 @@ describe("newDocumentProblem", () => {
|
|
|
97
160
|
expect(text).toContain("import { `source` }");
|
|
98
161
|
expect(text).toContain("view: is_tile is `is`");
|
|
99
162
|
expect(lintNotebookText("notebooks/sales.malloy", text)).toEqual([]);
|
|
100
|
-
expect(
|
|
101
|
-
newDocumentProblem("dashboard", { ...INPUT, source: "date" }),
|
|
102
|
-
).toMatch(/source name/);
|
|
163
|
+
expect(newDocumentProblem({ ...INPUT, source: "date" })).toBeUndefined();
|
|
103
164
|
});
|
|
104
165
|
|
|
105
166
|
it("trims the title once, for the tag and the heading", () => {
|
|
@@ -109,48 +170,57 @@ describe("newDocumentProblem", () => {
|
|
|
109
170
|
});
|
|
110
171
|
|
|
111
172
|
it("refuses names that cannot be written", () => {
|
|
112
|
-
expect(
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
expect(
|
|
116
|
-
|
|
117
|
-
)
|
|
118
|
-
expect(newDocumentProblem(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
173
|
+
expect(newDocumentProblem({ ...INPUT, view: "a`b" })).toMatch(
|
|
174
|
+
/view name/,
|
|
175
|
+
);
|
|
176
|
+
expect(newDocumentProblem({ ...INPUT, modelPath: 'a".malloy' })).toMatch(
|
|
177
|
+
/model path/,
|
|
178
|
+
);
|
|
179
|
+
expect(newDocumentProblem(INPUT)).toBeUndefined();
|
|
180
|
+
// Both layouts write the tag as a `##|` block, which `|##` would close.
|
|
181
|
+
expect(newDocumentProblem({ ...INPUT, title: "a |## b" })).toMatch(
|
|
182
|
+
/\|##/,
|
|
183
|
+
);
|
|
122
184
|
});
|
|
123
185
|
});
|
|
124
186
|
|
|
125
|
-
describe("
|
|
187
|
+
describe("report paths", () => {
|
|
126
188
|
it("always satisfy the server's write shape", () => {
|
|
127
189
|
let seed = 7;
|
|
128
190
|
const next = () => (seed = (seed * 1103515245 + 12345) & 0x7fffffff);
|
|
129
191
|
const alphabet = "aZ09 -_/\\.\"'`#%\n\té中\u{1f600}*()[]";
|
|
130
|
-
const shape = /^
|
|
192
|
+
const shape = /^[^/]+\.malloy$/;
|
|
131
193
|
for (let i = 0; i < 500; i++) {
|
|
132
194
|
const length = next() % 40;
|
|
133
195
|
let title = "";
|
|
134
196
|
for (let j = 0; j < length; j++)
|
|
135
197
|
title += [...alphabet][next() % [...alphabet].length];
|
|
136
|
-
for (const
|
|
137
|
-
|
|
138
|
-
|
|
198
|
+
for (const suffix of [1, 2, 19]) {
|
|
199
|
+
expect(reportPathForTitle(title, suffix)).toMatch(shape);
|
|
200
|
+
expect(reportPathForTitle(title, suffix, "team")).toMatch(
|
|
201
|
+
/^team\/[^/]+\.malloy$/,
|
|
202
|
+
);
|
|
203
|
+
}
|
|
139
204
|
}
|
|
140
205
|
});
|
|
141
206
|
|
|
142
|
-
it("spells suffixes -2, -3
|
|
143
|
-
expect(
|
|
144
|
-
|
|
145
|
-
);
|
|
146
|
-
expect(
|
|
147
|
-
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
207
|
+
it("spells suffixes -2, -3 at the package root, or in a directory asked for", () => {
|
|
208
|
+
expect(reportPathForTitle("Sales")).toBe("sales.malloy");
|
|
209
|
+
expect(reportPathForTitle("Sales", 3)).toBe("sales-3.malloy");
|
|
210
|
+
expect(reportPathForTitle("***")).toBe("untitled.malloy");
|
|
211
|
+
expect(reportPathFor(slugFor("A b"))).toBe("a-b.malloy");
|
|
212
|
+
expect(reportPathFor("a-b", "/team//q3/")).toBe("team/q3/a-b.malloy");
|
|
213
|
+
expect(reportPathFor("a-b", "")).toBe("a-b.malloy");
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
describe("the builder entry", () => {
|
|
217
|
+
it("exports the report path helpers, and no longer the kind-folder ones", async () => {
|
|
218
|
+
const builder: Record<string, unknown> = await import(
|
|
219
|
+
"../../builder-entry"
|
|
154
220
|
);
|
|
221
|
+
expect(typeof builder.reportPathFor).toBe("function");
|
|
222
|
+
expect(typeof builder.reportPathForTitle).toBe("function");
|
|
223
|
+
expect(builder.documentPathFor).toBeUndefined();
|
|
224
|
+
expect(builder.documentPathForTitle).toBeUndefined();
|
|
155
225
|
});
|
|
156
226
|
});
|