@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
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
createDocument,
|
|
14
14
|
createRoute,
|
|
15
15
|
MAX_SLUG_ATTEMPTS,
|
|
16
|
+
reportPathProblem,
|
|
16
17
|
} from "./createDocument";
|
|
17
18
|
|
|
18
19
|
const WORKSPACE: Workspace = {
|
|
@@ -29,17 +30,18 @@ const DOC = {
|
|
|
29
30
|
view: "by_category",
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
/** A store whose `saveDocument` replaces what is there, like the interface says. */
|
|
33
|
+
/** A store keyed by path whose `saveDocument` replaces what is there, like the interface says. */
|
|
33
34
|
class FakeStorage implements DocumentStorage {
|
|
34
35
|
readonly files = new Map<string, string>();
|
|
36
|
+
readonly layouts = new Map<string, DocumentType>();
|
|
35
37
|
readonly saves: string[] = [];
|
|
36
38
|
/** What `listDocuments` reports; defaults to the files, a stale test sets it. */
|
|
37
39
|
listing?: string[];
|
|
38
40
|
getFailure?: Error;
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.
|
|
42
|
+
seed(path: string, content = "original", layout: DocumentType = "grid") {
|
|
43
|
+
this.files.set(path, content);
|
|
44
|
+
this.layouts.set(path, layout);
|
|
43
45
|
}
|
|
44
46
|
async listWorkspaces() {
|
|
45
47
|
return [WORKSPACE];
|
|
@@ -47,24 +49,25 @@ class FakeStorage implements DocumentStorage {
|
|
|
47
49
|
async listDocuments(_w: Workspace, type?: DocumentType) {
|
|
48
50
|
const paths =
|
|
49
51
|
this.listing ??
|
|
50
|
-
[...this.files.keys()]
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
[...this.files.keys()].filter(
|
|
53
|
+
(path) => type === undefined || this.layouts.get(path) === type,
|
|
54
|
+
);
|
|
53
55
|
return paths.map((path) => ({
|
|
54
56
|
workspace: WORKSPACE.name,
|
|
55
|
-
type:
|
|
57
|
+
type: this.layouts.get(path) ?? "grid",
|
|
56
58
|
path,
|
|
57
59
|
}));
|
|
58
60
|
}
|
|
59
61
|
async getDocument(locator: DocumentLocator) {
|
|
60
62
|
if (this.getFailure) throw this.getFailure;
|
|
61
|
-
const text = this.files.get(
|
|
63
|
+
const text = this.files.get(locator.path);
|
|
62
64
|
if (text === undefined) throw new DocumentNotFoundError("absent");
|
|
63
65
|
return text;
|
|
64
66
|
}
|
|
65
67
|
async saveDocument(locator: DocumentLocator, content: string) {
|
|
66
68
|
this.saves.push(locator.path);
|
|
67
|
-
this.files.set(
|
|
69
|
+
this.files.set(locator.path, content);
|
|
70
|
+
this.layouts.set(locator.path, locator.type);
|
|
68
71
|
}
|
|
69
72
|
async deleteDocument() {}
|
|
70
73
|
async moveDocument() {}
|
|
@@ -85,56 +88,57 @@ describe("createDocument on the storage route", () => {
|
|
|
85
88
|
const created: unknown[] = [];
|
|
86
89
|
const events: unknown[] = [];
|
|
87
90
|
const result = await createDocument({
|
|
88
|
-
|
|
91
|
+
layout: "linear",
|
|
89
92
|
document: DOC,
|
|
90
93
|
target: target(storage),
|
|
91
94
|
onCreated: (c) => created.push(c),
|
|
92
95
|
onEvent: (e) => events.push(e),
|
|
93
96
|
});
|
|
94
|
-
expect(result.path).toBe("
|
|
97
|
+
expect(result.path).toBe("sales.malloy");
|
|
95
98
|
expect(result.slug).toBe("sales");
|
|
96
99
|
expect(result.locator).toEqual({
|
|
97
100
|
workspace: "record",
|
|
98
|
-
type: "
|
|
99
|
-
path: "env/pkg/
|
|
101
|
+
type: "linear",
|
|
102
|
+
path: "env/pkg/sales.malloy",
|
|
100
103
|
});
|
|
101
|
-
expect(storage.saves).toEqual(["env/pkg/
|
|
104
|
+
expect(storage.saves).toEqual(["env/pkg/sales.malloy"]);
|
|
102
105
|
expect(created).toEqual([result]);
|
|
103
|
-
expect(events).
|
|
106
|
+
expect(events).toMatchObject([
|
|
107
|
+
{
|
|
108
|
+
type: "report.created",
|
|
109
|
+
where: "host",
|
|
110
|
+
path: "sales.malloy",
|
|
111
|
+
layout: "linear",
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
104
114
|
});
|
|
105
115
|
|
|
106
116
|
it("takes the next name when the listing shows the slug", async () => {
|
|
107
117
|
const storage = new FakeStorage();
|
|
108
|
-
storage.seed("
|
|
118
|
+
storage.seed("env/pkg/sales.malloy");
|
|
109
119
|
const result = await createDocument({
|
|
110
|
-
|
|
120
|
+
layout: "grid",
|
|
111
121
|
document: DOC,
|
|
112
122
|
target: target(storage),
|
|
113
123
|
});
|
|
114
124
|
expect(result.slug).toBe("sales-2");
|
|
115
|
-
expect(
|
|
116
|
-
storage.files.get("dashboard:env/pkg/dashboards/sales.malloy"),
|
|
117
|
-
).toBe("original");
|
|
125
|
+
expect(storage.files.get("env/pkg/sales.malloy")).toBe("original");
|
|
118
126
|
});
|
|
119
127
|
|
|
120
128
|
it("never overwrites a file a stale listing misses", async () => {
|
|
121
129
|
const storage = new FakeStorage();
|
|
122
|
-
storage.seed("
|
|
123
|
-
storage.seed("
|
|
130
|
+
storage.seed("env/pkg/sales.malloy");
|
|
131
|
+
storage.seed("env/pkg/sales-2.malloy", "two");
|
|
124
132
|
storage.listing = [];
|
|
125
133
|
const result = await createDocument({
|
|
126
|
-
|
|
134
|
+
layout: "grid",
|
|
127
135
|
document: DOC,
|
|
128
136
|
target: target(storage),
|
|
129
137
|
});
|
|
130
138
|
expect(result.slug).toBe("sales-3");
|
|
131
|
-
expect(storage.saves).toEqual(["env/pkg/
|
|
132
|
-
expect(
|
|
133
|
-
|
|
134
|
-
).toBe("original");
|
|
135
|
-
expect(
|
|
136
|
-
storage.files.get("dashboard:env/pkg/dashboards/sales-2.malloy"),
|
|
137
|
-
).toBe("two");
|
|
139
|
+
expect(storage.saves).toEqual(["env/pkg/sales-3.malloy"]);
|
|
140
|
+
expect(storage.files.get("env/pkg/sales.malloy")).toBe("original");
|
|
141
|
+
expect(storage.files.get("env/pkg/sales-2.malloy")).toBe("two");
|
|
138
142
|
});
|
|
139
143
|
|
|
140
144
|
it("aborts, saving nothing, when the read fails for any reason but absence", async () => {
|
|
@@ -142,7 +146,7 @@ describe("createDocument on the storage route", () => {
|
|
|
142
146
|
storage.getFailure = new Error("backend down");
|
|
143
147
|
await expect(
|
|
144
148
|
createDocument({
|
|
145
|
-
|
|
149
|
+
layout: "grid",
|
|
146
150
|
document: DOC,
|
|
147
151
|
target: target(storage),
|
|
148
152
|
}),
|
|
@@ -153,12 +157,12 @@ describe("createDocument on the storage route", () => {
|
|
|
153
157
|
it("gives up after the attempt cap rather than looping", async () => {
|
|
154
158
|
const storage = new FakeStorage();
|
|
155
159
|
storage.listing = [];
|
|
156
|
-
storage.seed("
|
|
160
|
+
storage.seed("env/pkg/sales.malloy");
|
|
157
161
|
for (let n = 2; n <= MAX_SLUG_ATTEMPTS; n++)
|
|
158
|
-
storage.seed(
|
|
162
|
+
storage.seed(`env/pkg/sales-${n}.malloy`);
|
|
159
163
|
await expect(
|
|
160
164
|
createDocument({
|
|
161
|
-
|
|
165
|
+
layout: "grid",
|
|
162
166
|
document: DOC,
|
|
163
167
|
target: target(storage),
|
|
164
168
|
}),
|
|
@@ -171,7 +175,7 @@ describe("createDocument on the storage route", () => {
|
|
|
171
175
|
for (const title of ["a\nb", "x ##(authorize) y", " "]) {
|
|
172
176
|
await expect(
|
|
173
177
|
createDocument({
|
|
174
|
-
|
|
178
|
+
layout: "linear",
|
|
175
179
|
document: { ...DOC, title },
|
|
176
180
|
target: target(storage),
|
|
177
181
|
}),
|
|
@@ -186,11 +190,11 @@ describe("createDocument on the package route", () => {
|
|
|
186
190
|
const writes: Array<[string, string]> = [];
|
|
187
191
|
const events: unknown[] = [];
|
|
188
192
|
const result = await createDocument({
|
|
189
|
-
|
|
193
|
+
layout: "grid",
|
|
190
194
|
document: DOC,
|
|
191
195
|
target: {
|
|
192
196
|
route: "package",
|
|
193
|
-
existing: ["
|
|
197
|
+
existing: ["sales.malloy", "other/sales.malloy"],
|
|
194
198
|
write: async (path, source) => {
|
|
195
199
|
writes.push([path, source]);
|
|
196
200
|
},
|
|
@@ -198,20 +202,27 @@ describe("createDocument on the package route", () => {
|
|
|
198
202
|
onEvent: (e) => events.push(e),
|
|
199
203
|
});
|
|
200
204
|
expect(result).toEqual({
|
|
201
|
-
|
|
202
|
-
path: "
|
|
205
|
+
layout: "grid",
|
|
206
|
+
path: "sales-2.malloy",
|
|
203
207
|
slug: "sales-2",
|
|
204
208
|
});
|
|
205
|
-
expect(writes.map(([p]) => p)).toEqual(["
|
|
206
|
-
expect(writes[0][1]).toContain("
|
|
207
|
-
expect(events).
|
|
209
|
+
expect(writes.map(([p]) => p)).toEqual(["sales-2.malloy"]);
|
|
210
|
+
expect(writes[0][1]).toContain("##| artifact { layout=grid");
|
|
211
|
+
expect(events).toMatchObject([
|
|
212
|
+
{
|
|
213
|
+
type: "report.created",
|
|
214
|
+
where: "package",
|
|
215
|
+
path: "sales-2.malloy",
|
|
216
|
+
layout: "grid",
|
|
217
|
+
},
|
|
218
|
+
]);
|
|
208
219
|
});
|
|
209
220
|
|
|
210
|
-
it("
|
|
221
|
+
it("reports a create the server refused as refused, never as created", async () => {
|
|
211
222
|
const events: unknown[] = [];
|
|
212
223
|
await expect(
|
|
213
224
|
createDocument({
|
|
214
|
-
|
|
225
|
+
layout: "linear",
|
|
215
226
|
document: DOC,
|
|
216
227
|
target: {
|
|
217
228
|
route: "package",
|
|
@@ -223,7 +234,14 @@ describe("createDocument on the package route", () => {
|
|
|
223
234
|
onEvent: (e) => events.push(e),
|
|
224
235
|
}),
|
|
225
236
|
).rejects.toThrow("409");
|
|
226
|
-
expect(events).toEqual([
|
|
237
|
+
expect(events).toEqual([
|
|
238
|
+
{
|
|
239
|
+
type: "report.create_refused",
|
|
240
|
+
reason: "409",
|
|
241
|
+
path: "",
|
|
242
|
+
layout: "linear",
|
|
243
|
+
},
|
|
244
|
+
]);
|
|
227
245
|
});
|
|
228
246
|
});
|
|
229
247
|
|
|
@@ -231,11 +249,11 @@ describe("createDocument names", () => {
|
|
|
231
249
|
it("on the storage route, skips a path the package listing has", async () => {
|
|
232
250
|
const storage = new FakeStorage();
|
|
233
251
|
const result = await createDocument({
|
|
234
|
-
|
|
252
|
+
layout: "grid",
|
|
235
253
|
document: DOC,
|
|
236
254
|
target: {
|
|
237
255
|
...target(storage),
|
|
238
|
-
existing: ["
|
|
256
|
+
existing: ["sales.malloy"],
|
|
239
257
|
},
|
|
240
258
|
});
|
|
241
259
|
expect(result.slug).toBe("sales-2");
|
|
@@ -244,7 +262,7 @@ describe("createDocument names", () => {
|
|
|
244
262
|
it("on the package route, moves to the next name when the server answers 409", async () => {
|
|
245
263
|
const tried: string[] = [];
|
|
246
264
|
const result = await createDocument({
|
|
247
|
-
|
|
265
|
+
layout: "grid",
|
|
248
266
|
document: DOC,
|
|
249
267
|
target: {
|
|
250
268
|
route: "package",
|
|
@@ -259,9 +277,9 @@ describe("createDocument names", () => {
|
|
|
259
277
|
},
|
|
260
278
|
});
|
|
261
279
|
expect(tried).toEqual([
|
|
262
|
-
"
|
|
263
|
-
"
|
|
264
|
-
"
|
|
280
|
+
"sales.malloy",
|
|
281
|
+
"sales-2.malloy",
|
|
282
|
+
"sales-3.malloy",
|
|
265
283
|
]);
|
|
266
284
|
expect(result.slug).toBe("sales-3");
|
|
267
285
|
});
|
|
@@ -270,7 +288,7 @@ describe("createDocument names", () => {
|
|
|
270
288
|
let writes = 0;
|
|
271
289
|
await expect(
|
|
272
290
|
createDocument({
|
|
273
|
-
|
|
291
|
+
layout: "grid",
|
|
274
292
|
document: DOC,
|
|
275
293
|
target: {
|
|
276
294
|
route: "package",
|
|
@@ -308,3 +326,278 @@ describe("createRoute", () => {
|
|
|
308
326
|
).toBeUndefined();
|
|
309
327
|
});
|
|
310
328
|
});
|
|
329
|
+
|
|
330
|
+
describe("createDocument at a path", () => {
|
|
331
|
+
const write = () => {
|
|
332
|
+
const writes: Array<[string, string]> = [];
|
|
333
|
+
return {
|
|
334
|
+
writes,
|
|
335
|
+
target: {
|
|
336
|
+
route: "package" as const,
|
|
337
|
+
existing: ["taken.malloy"],
|
|
338
|
+
write: async (path: string, source: string) => {
|
|
339
|
+
writes.push([path, source]);
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
it("writes `<slug>.malloy` at the package root, importing the model beside it", async () => {
|
|
346
|
+
const { writes, target: t } = write();
|
|
347
|
+
const result = await createDocument({
|
|
348
|
+
layout: "linear",
|
|
349
|
+
document: { ...DOC, modelPath: "storefront.malloy" },
|
|
350
|
+
target: t,
|
|
351
|
+
});
|
|
352
|
+
expect(result).toEqual({
|
|
353
|
+
layout: "linear",
|
|
354
|
+
path: "sales.malloy",
|
|
355
|
+
slug: "sales",
|
|
356
|
+
});
|
|
357
|
+
expect(writes[0][1]).toContain(
|
|
358
|
+
'import { order_items } from "storefront.malloy"',
|
|
359
|
+
);
|
|
360
|
+
expect(writes[0][1]).toContain("layout=linear");
|
|
361
|
+
expect(writes[0][1]).not.toContain("kind=notebook");
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it("defaults to a linear report", async () => {
|
|
365
|
+
const { target: t } = write();
|
|
366
|
+
const result = await createDocument({ document: DOC, target: t });
|
|
367
|
+
expect(result.layout).toBe("linear");
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
it("writes at a nested path, with the import relative to it", async () => {
|
|
371
|
+
const { writes, target: t } = write();
|
|
372
|
+
const result = await createDocument({
|
|
373
|
+
layout: "grid",
|
|
374
|
+
path: "team/sales.malloy",
|
|
375
|
+
document: { ...DOC, modelPath: "m.malloy" },
|
|
376
|
+
target: t,
|
|
377
|
+
});
|
|
378
|
+
expect(result.path).toBe("team/sales.malloy");
|
|
379
|
+
expect(result.slug).toBe("sales");
|
|
380
|
+
expect(writes[0][0]).toBe("team/sales.malloy");
|
|
381
|
+
expect(writes[0][1]).toContain('from "../m.malloy"');
|
|
382
|
+
expect(writes[0][1]).toContain("layout=grid");
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it("puts a title-named file in a directory", async () => {
|
|
386
|
+
const { writes, target: t } = write();
|
|
387
|
+
await createDocument({
|
|
388
|
+
directory: "/team/",
|
|
389
|
+
document: DOC,
|
|
390
|
+
target: t,
|
|
391
|
+
});
|
|
392
|
+
expect(writes[0][0]).toBe("team/sales.malloy");
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it("refuses a taken path rather than renaming it", async () => {
|
|
396
|
+
const { writes, target: t } = write();
|
|
397
|
+
await expect(
|
|
398
|
+
createDocument({ path: "taken.malloy", document: DOC, target: t }),
|
|
399
|
+
).rejects.toThrow("taken.malloy already exists");
|
|
400
|
+
expect(writes).toEqual([]);
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it("refuses a path the server answers 409 for, once", async () => {
|
|
404
|
+
const tried: string[] = [];
|
|
405
|
+
await expect(
|
|
406
|
+
createDocument({
|
|
407
|
+
path: "x.malloy",
|
|
408
|
+
document: DOC,
|
|
409
|
+
target: {
|
|
410
|
+
route: "package",
|
|
411
|
+
existing: [],
|
|
412
|
+
write: async (path) => {
|
|
413
|
+
tried.push(path);
|
|
414
|
+
throw Object.assign(new Error("exists"), {
|
|
415
|
+
response: { status: 409 },
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
}),
|
|
420
|
+
).rejects.toThrow("already exists");
|
|
421
|
+
expect(tried).toEqual(["x.malloy"]);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it("refuses a path a report cannot live at, before writing", async () => {
|
|
425
|
+
for (const path of [
|
|
426
|
+
"public/x.malloy",
|
|
427
|
+
"index.malloy",
|
|
428
|
+
"../x.malloy",
|
|
429
|
+
"a/../x.malloy",
|
|
430
|
+
"/x.malloy",
|
|
431
|
+
"x.txt",
|
|
432
|
+
"x",
|
|
433
|
+
"dir/.malloy",
|
|
434
|
+
]) {
|
|
435
|
+
const { writes, target: t } = write();
|
|
436
|
+
await expect(
|
|
437
|
+
createDocument({ path, document: DOC, target: t }),
|
|
438
|
+
).rejects.toThrow();
|
|
439
|
+
expect(writes).toEqual([]);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
describe("createDocument in a directory", () => {
|
|
445
|
+
const BAD_DIRECTORIES = [
|
|
446
|
+
"../x",
|
|
447
|
+
"a/../../x",
|
|
448
|
+
"public",
|
|
449
|
+
"Public/reports",
|
|
450
|
+
"./x",
|
|
451
|
+
];
|
|
452
|
+
|
|
453
|
+
it("refuses a directory a report cannot live in, before the package is written", async () => {
|
|
454
|
+
for (const directory of BAD_DIRECTORIES) {
|
|
455
|
+
const writes: string[] = [];
|
|
456
|
+
await expect(
|
|
457
|
+
createDocument({
|
|
458
|
+
directory,
|
|
459
|
+
document: DOC,
|
|
460
|
+
target: {
|
|
461
|
+
route: "package",
|
|
462
|
+
existing: [],
|
|
463
|
+
write: async (path) => {
|
|
464
|
+
writes.push(path);
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
}),
|
|
468
|
+
).rejects.toThrow();
|
|
469
|
+
expect(writes).toEqual([]);
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
it("refuses it before the store is asked anything", async () => {
|
|
474
|
+
for (const directory of BAD_DIRECTORIES) {
|
|
475
|
+
const storage = new FakeStorage();
|
|
476
|
+
let asked = 0;
|
|
477
|
+
storage.listDocuments = async () => {
|
|
478
|
+
asked++;
|
|
479
|
+
return [];
|
|
480
|
+
};
|
|
481
|
+
storage.getDocument = async () => {
|
|
482
|
+
asked++;
|
|
483
|
+
throw new DocumentNotFoundError("absent");
|
|
484
|
+
};
|
|
485
|
+
await expect(
|
|
486
|
+
createDocument({
|
|
487
|
+
directory,
|
|
488
|
+
document: DOC,
|
|
489
|
+
target: target(storage),
|
|
490
|
+
}),
|
|
491
|
+
).rejects.toThrow();
|
|
492
|
+
expect(asked).toBe(0);
|
|
493
|
+
expect(storage.saves).toEqual([]);
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
it("still writes into a directory that is fine", async () => {
|
|
498
|
+
const writes: string[] = [];
|
|
499
|
+
const created = await createDocument({
|
|
500
|
+
directory: "team/q3",
|
|
501
|
+
document: DOC,
|
|
502
|
+
target: {
|
|
503
|
+
route: "package",
|
|
504
|
+
existing: [],
|
|
505
|
+
write: async (path) => {
|
|
506
|
+
writes.push(path);
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
});
|
|
510
|
+
expect(created.path).toBe("team/q3/sales.malloy");
|
|
511
|
+
expect(writes).toEqual(["team/q3/sales.malloy"]);
|
|
512
|
+
});
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
describe("reportPathProblem", () => {
|
|
516
|
+
it("accepts a path anywhere in the package outside public/", () => {
|
|
517
|
+
for (const path of [
|
|
518
|
+
"x.malloy",
|
|
519
|
+
"sales/q3.malloy",
|
|
520
|
+
"dashboards/x.malloy",
|
|
521
|
+
"notebooks/a/b.malloy",
|
|
522
|
+
"sub/index.malloy",
|
|
523
|
+
])
|
|
524
|
+
expect(reportPathProblem(path)).toBeUndefined();
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
it("names why a path is refused", () => {
|
|
528
|
+
expect(reportPathProblem("public/x.malloy")).toContain("public/");
|
|
529
|
+
// On a case-insensitive file system these land in public/ too.
|
|
530
|
+
expect(reportPathProblem("Public/x.malloy")).toContain("public/");
|
|
531
|
+
expect(reportPathProblem("PUBLIC/a/x.malloy")).toContain("public/");
|
|
532
|
+
expect(reportPathProblem("publications/x.malloy")).toBeUndefined();
|
|
533
|
+
expect(reportPathProblem("index.malloy")).toContain("index.malloy");
|
|
534
|
+
// As the server refuses it: on a case-insensitive file system it is the surface.
|
|
535
|
+
expect(reportPathProblem("Index.malloy")).toContain("index.malloy");
|
|
536
|
+
expect(reportPathProblem("sales/Index.malloy")).toBeUndefined();
|
|
537
|
+
expect(reportPathProblem("../x.malloy")).toContain("inside the package");
|
|
538
|
+
expect(reportPathProblem("x.malloynb")).toContain(".malloy");
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* A host store that files documents by layout, as a host may:
|
|
544
|
+
* whatever path the locator asks for, the file lands in `dashboards/` or
|
|
545
|
+
* `notebooks/` under its basename.
|
|
546
|
+
*/
|
|
547
|
+
class RelocatingStorage extends FakeStorage {
|
|
548
|
+
readonly written = new Map<string, string>();
|
|
549
|
+
relocate = (locator: DocumentLocator) => {
|
|
550
|
+
const base = locator.path.slice(locator.path.lastIndexOf("/") + 1);
|
|
551
|
+
return `${locator.type === "grid" ? "dashboards" : "notebooks"}/${base}`;
|
|
552
|
+
};
|
|
553
|
+
resolveDocumentPath(locator: DocumentLocator) {
|
|
554
|
+
return this.relocate(locator);
|
|
555
|
+
}
|
|
556
|
+
async saveDocument(locator: DocumentLocator, content: string) {
|
|
557
|
+
await super.saveDocument(locator, content);
|
|
558
|
+
this.written.set(this.relocate(locator), content);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
describe("createDocument into a store that chooses the file's place", () => {
|
|
563
|
+
it("writes the import for where the store puts the file, and returns that path", async () => {
|
|
564
|
+
const storage = new RelocatingStorage();
|
|
565
|
+
const created = await createDocument({
|
|
566
|
+
layout: "grid",
|
|
567
|
+
document: DOC,
|
|
568
|
+
target: target(storage),
|
|
569
|
+
});
|
|
570
|
+
expect(created.path).toBe("dashboards/sales.malloy");
|
|
571
|
+
expect(created.slug).toBe("sales");
|
|
572
|
+
const text = storage.written.get("dashboards/sales.malloy")!;
|
|
573
|
+
expect(text).toContain(
|
|
574
|
+
'import { order_items } from "../models/storefront.malloy"',
|
|
575
|
+
);
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
it("skips a name whose real place the package already has", async () => {
|
|
579
|
+
const storage = new RelocatingStorage();
|
|
580
|
+
const created = await createDocument({
|
|
581
|
+
layout: "linear",
|
|
582
|
+
document: DOC,
|
|
583
|
+
target: {
|
|
584
|
+
...target(storage),
|
|
585
|
+
existing: ["notebooks/sales.malloy"],
|
|
586
|
+
},
|
|
587
|
+
});
|
|
588
|
+
expect(created.path).toBe("notebooks/sales-2.malloy");
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
it("falls back to the requested path for a store that says nothing", async () => {
|
|
592
|
+
const storage = new FakeStorage();
|
|
593
|
+
const created = await createDocument({
|
|
594
|
+
layout: "grid",
|
|
595
|
+
document: DOC,
|
|
596
|
+
target: target(storage),
|
|
597
|
+
});
|
|
598
|
+
expect(created.path).toBe("sales.malloy");
|
|
599
|
+
expect(storage.files.get("env/pkg/sales.malloy")).toContain(
|
|
600
|
+
'from "models/storefront.malloy"',
|
|
601
|
+
);
|
|
602
|
+
});
|
|
603
|
+
});
|