@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
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { importPathOf } from "../ReportBuilder/imports";
|
|
5
|
+
import type { ReportLayout } from "../Package/documentLocation";
|
|
4
6
|
import { malloyName, newDocumentProblem, type NewDocument } from "./guards";
|
|
5
7
|
|
|
8
|
+
/** Where a new report goes when nobody says otherwise: the package root. */
|
|
9
|
+
const ROOT_REPORT_PATH = "report.malloy";
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
|
-
* A new
|
|
8
|
-
*
|
|
9
|
-
* import of the one source it runs (
|
|
10
|
-
* the
|
|
12
|
+
* A new report file, in the format the builder writes: the givens flag, the
|
|
13
|
+
* artifact tag (a block, a tile per line) listing an intro text tile and one
|
|
14
|
+
* query tile, a named import of the one source it runs (written relative to
|
|
15
|
+
* where the report sits, so a report at the root imports `"<model>"`), the
|
|
16
|
+
* intro block, and one extension of the source (`<source>_tiles`, the
|
|
11
17
|
* builder's naming) holding the picked view as the query tile.
|
|
18
|
+
*
|
|
19
|
+
* The two layouts differ only in `layout=` and the grid tag a grid carries.
|
|
20
|
+
* `layout=` is always written, so the file never depends on the reading rule.
|
|
12
21
|
*/
|
|
13
|
-
export function
|
|
14
|
-
|
|
22
|
+
export function newReportSource(
|
|
23
|
+
input: NewDocument,
|
|
24
|
+
layout: ReportLayout,
|
|
25
|
+
/** The package path the report is written at; the import is relative to it. Default: the root. */
|
|
26
|
+
reportPath: string = ROOT_REPORT_PATH,
|
|
27
|
+
): string {
|
|
28
|
+
const problem = newDocumentProblem(input);
|
|
15
29
|
if (problem) throw new Error(problem);
|
|
16
30
|
const { modelPath, source, view } = input;
|
|
17
31
|
const title = input.title.trim();
|
|
@@ -22,18 +36,18 @@ export function newNotebookSource(input: NewDocument): string {
|
|
|
22
36
|
const entry = `"${extension} -> ${tile}"`;
|
|
23
37
|
return [
|
|
24
38
|
"##! experimental.givens",
|
|
25
|
-
`##| artifact {
|
|
39
|
+
`##| artifact { layout=${layout} title=${quoted}`,
|
|
26
40
|
" tiles=[",
|
|
27
41
|
" intro { kind=text },",
|
|
28
42
|
` ${entry}`,
|
|
29
43
|
" ]",
|
|
30
|
-
"}",
|
|
44
|
+
layout === "grid" ? "} dashboard { columns=12 }" : "}",
|
|
31
45
|
"|##",
|
|
32
|
-
`import { ${malloyName(source)} } from "
|
|
46
|
+
`import { ${malloyName(source)} } from "${importPathOf(modelPath, reportPath)}"`,
|
|
33
47
|
"",
|
|
34
48
|
"##|(markdown) intro",
|
|
35
49
|
`# ${title}`,
|
|
36
|
-
"Say what this
|
|
50
|
+
"Say what this report is for, then let the queries below answer it.",
|
|
37
51
|
"|##",
|
|
38
52
|
"",
|
|
39
53
|
`source: ${extension} is ${malloyName(source)} extend {`,
|
|
@@ -42,3 +56,11 @@ export function newNotebookSource(input: NewDocument): string {
|
|
|
42
56
|
"",
|
|
43
57
|
].join("\n");
|
|
44
58
|
}
|
|
59
|
+
|
|
60
|
+
/** A new linear report; see {@link newReportSource}. */
|
|
61
|
+
export function newNotebookSource(
|
|
62
|
+
input: NewDocument,
|
|
63
|
+
reportPath?: string,
|
|
64
|
+
): string {
|
|
65
|
+
return newReportSource(input, "linear", reportPath);
|
|
66
|
+
}
|
|
@@ -6,15 +6,15 @@ import { BrowserDocumentStorage } from "./BrowserDocumentStorage";
|
|
|
6
6
|
import type { DocumentLocator, Workspace } from "./DocumentStorage";
|
|
7
7
|
|
|
8
8
|
const local: Workspace = { name: "Local", writeable: true, description: "" };
|
|
9
|
-
const
|
|
9
|
+
const grid: DocumentLocator = {
|
|
10
10
|
workspace: "Local",
|
|
11
|
-
type: "
|
|
12
|
-
path: "dashboards/overview.malloy",
|
|
11
|
+
type: "grid",
|
|
12
|
+
path: "env/pkg/dashboards/overview.malloy",
|
|
13
13
|
};
|
|
14
|
-
const
|
|
14
|
+
const linear: DocumentLocator = {
|
|
15
15
|
workspace: "Local",
|
|
16
|
-
type: "
|
|
17
|
-
path: "tour.
|
|
16
|
+
type: "linear",
|
|
17
|
+
path: "env/pkg/tour.malloy",
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
describe("BrowserDocumentStorage", () => {
|
|
@@ -22,47 +22,80 @@ describe("BrowserDocumentStorage", () => {
|
|
|
22
22
|
|
|
23
23
|
it("round-trips a document", async () => {
|
|
24
24
|
const store = new BrowserDocumentStorage();
|
|
25
|
-
await store.saveDocument(
|
|
26
|
-
expect(await store.getDocument(
|
|
27
|
-
"## artifact { tiles=[] }",
|
|
28
|
-
);
|
|
25
|
+
await store.saveDocument(grid, "## artifact { tiles=[] }");
|
|
26
|
+
expect(await store.getDocument(grid)).toBe("## artifact { tiles=[] }");
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
it("lists its own documents, by
|
|
29
|
+
it("lists its own documents with their layouts, by layout, and nothing else in localStorage", async () => {
|
|
32
30
|
const store = new BrowserDocumentStorage();
|
|
33
31
|
localStorage.setItem("publisher:themeMode", "dark");
|
|
34
|
-
await store.saveDocument(
|
|
35
|
-
await store.saveDocument(
|
|
32
|
+
await store.saveDocument(grid, "a");
|
|
33
|
+
await store.saveDocument(linear, "b");
|
|
36
34
|
expect(await store.listDocuments(local)).toEqual(
|
|
37
|
-
expect.arrayContaining([
|
|
35
|
+
expect.arrayContaining([grid, linear]),
|
|
38
36
|
);
|
|
39
37
|
expect(await store.listDocuments(local)).toHaveLength(2);
|
|
40
|
-
expect(await store.listDocuments(local, "
|
|
38
|
+
expect(await store.listDocuments(local, "linear")).toEqual([linear]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("keys a document by its path alone: a save under another layout replaces it and records that layout", async () => {
|
|
42
|
+
const store = new BrowserDocumentStorage();
|
|
43
|
+
await store.saveDocument(grid, "as a grid");
|
|
44
|
+
const switched = { ...grid, type: "linear" as const };
|
|
45
|
+
await store.saveDocument(switched, "as linear");
|
|
46
|
+
expect(await store.getDocument(grid)).toBe("as linear");
|
|
47
|
+
expect(await store.listDocuments(local)).toEqual([switched]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("reads one document's layout by its path, without listing, and rejects when absent", async () => {
|
|
51
|
+
const store = new BrowserDocumentStorage();
|
|
52
|
+
await store.saveDocument(linear, "b");
|
|
53
|
+
store.listDocuments = () => {
|
|
54
|
+
throw new Error("listed");
|
|
55
|
+
};
|
|
56
|
+
expect(
|
|
57
|
+
await store.getDocumentType({
|
|
58
|
+
workspace: "Local",
|
|
59
|
+
path: linear.path,
|
|
60
|
+
}),
|
|
61
|
+
).toBe("linear");
|
|
62
|
+
const absent = store.getDocumentType({
|
|
63
|
+
workspace: "Local",
|
|
64
|
+
path: grid.path,
|
|
65
|
+
});
|
|
66
|
+
await expect(absent).rejects.toThrow(/No report/);
|
|
67
|
+
await expect(absent).rejects.toHaveProperty(
|
|
68
|
+
"name",
|
|
69
|
+
"DocumentNotFoundError",
|
|
70
|
+
);
|
|
41
71
|
});
|
|
42
72
|
|
|
43
|
-
it("keeps a path containing
|
|
73
|
+
it("keeps a path containing a colon intact", async () => {
|
|
44
74
|
const store = new BrowserDocumentStorage();
|
|
45
|
-
const odd = { ...
|
|
75
|
+
const odd = { ...grid, path: "env/pkg/dashboards/a:b.malloy" };
|
|
46
76
|
await store.saveDocument(odd, "x");
|
|
47
|
-
expect(await store.listDocuments(local, "
|
|
77
|
+
expect(await store.listDocuments(local, "grid")).toEqual([odd]);
|
|
48
78
|
});
|
|
49
79
|
|
|
50
80
|
it("rejects a read, delete or move of a document that is not there", async () => {
|
|
51
81
|
const store = new BrowserDocumentStorage();
|
|
52
|
-
await expect(store.getDocument(
|
|
53
|
-
|
|
54
|
-
);
|
|
55
|
-
await expect(store.deleteDocument(dashboard)).rejects.toThrow();
|
|
56
|
-
await expect(store.moveDocument(dashboard, notebook)).rejects.toThrow();
|
|
82
|
+
await expect(store.getDocument(grid)).rejects.toThrow(/No report/);
|
|
83
|
+
await expect(store.deleteDocument(grid)).rejects.toThrow();
|
|
84
|
+
await expect(store.moveDocument(grid, linear)).rejects.toThrow();
|
|
57
85
|
});
|
|
58
86
|
|
|
59
|
-
it("moves a document, content intact, and forgets the old address", async () => {
|
|
87
|
+
it("moves a document, content intact, records the new layout, and forgets the old address", async () => {
|
|
60
88
|
const store = new BrowserDocumentStorage();
|
|
61
|
-
await store.saveDocument(
|
|
62
|
-
const renamed = {
|
|
63
|
-
|
|
89
|
+
await store.saveDocument(grid, "content");
|
|
90
|
+
const renamed = {
|
|
91
|
+
...grid,
|
|
92
|
+
type: "linear" as const,
|
|
93
|
+
path: "env/pkg/sales.malloy",
|
|
94
|
+
};
|
|
95
|
+
await store.moveDocument(grid, renamed);
|
|
64
96
|
expect(await store.getDocument(renamed)).toBe("content");
|
|
65
|
-
await
|
|
97
|
+
expect(await store.listDocuments(local)).toEqual([renamed]);
|
|
98
|
+
await expect(store.getDocument(grid)).rejects.toThrow();
|
|
66
99
|
});
|
|
67
100
|
|
|
68
101
|
it("has one writeable workspace and lists nothing for any other", async () => {
|
|
@@ -78,4 +111,73 @@ describe("BrowserDocumentStorage", () => {
|
|
|
78
111
|
}),
|
|
79
112
|
).toEqual([]);
|
|
80
113
|
});
|
|
114
|
+
|
|
115
|
+
it("ignores a key of its own prefix that does not hold a document", async () => {
|
|
116
|
+
localStorage.setItem("publisher:report:env/pkg/x.malloy", "not json");
|
|
117
|
+
const store = new BrowserDocumentStorage();
|
|
118
|
+
expect(await store.listDocuments(local)).toEqual([]);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe("BrowserDocumentStorage: drafts saved under the old type-keyed scheme", () => {
|
|
123
|
+
beforeEach(() => localStorage.clear());
|
|
124
|
+
|
|
125
|
+
it("moves each to its path, its old type read as its layout, the first time the store is used", async () => {
|
|
126
|
+
localStorage.setItem(
|
|
127
|
+
"publisher:document:dashboard:env/pkg/sales/q3.malloy",
|
|
128
|
+
"grid draft",
|
|
129
|
+
);
|
|
130
|
+
localStorage.setItem(
|
|
131
|
+
"publisher:document:notebook:env/pkg/story.malloy",
|
|
132
|
+
"linear draft",
|
|
133
|
+
);
|
|
134
|
+
const store = new BrowserDocumentStorage();
|
|
135
|
+
expect(
|
|
136
|
+
(await store.listDocuments(local)).sort((a, b) =>
|
|
137
|
+
a.path.localeCompare(b.path),
|
|
138
|
+
),
|
|
139
|
+
).toEqual([
|
|
140
|
+
{ workspace: "Local", type: "grid", path: "env/pkg/sales/q3.malloy" },
|
|
141
|
+
{ workspace: "Local", type: "linear", path: "env/pkg/story.malloy" },
|
|
142
|
+
]);
|
|
143
|
+
expect(
|
|
144
|
+
await store.getDocument({ ...linear, path: "env/pkg/story.malloy" }),
|
|
145
|
+
).toBe("linear draft");
|
|
146
|
+
expect(
|
|
147
|
+
localStorage.getItem(
|
|
148
|
+
"publisher:document:dashboard:env/pkg/sales/q3.malloy",
|
|
149
|
+
),
|
|
150
|
+
).toBeNull();
|
|
151
|
+
expect(
|
|
152
|
+
localStorage.getItem(
|
|
153
|
+
"publisher:document:notebook:env/pkg/story.malloy",
|
|
154
|
+
),
|
|
155
|
+
).toBeNull();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("is found by a read before any listing", async () => {
|
|
159
|
+
localStorage.setItem(
|
|
160
|
+
"publisher:document:notebook:env/pkg/tour.malloy",
|
|
161
|
+
"kept",
|
|
162
|
+
);
|
|
163
|
+
expect(await new BrowserDocumentStorage().getDocument(linear)).toBe(
|
|
164
|
+
"kept",
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("never overwrites a document already at the path: the old copy stays where it was", async () => {
|
|
169
|
+
const store = new BrowserDocumentStorage();
|
|
170
|
+
await store.saveDocument(linear, "current");
|
|
171
|
+
localStorage.setItem(
|
|
172
|
+
"publisher:document:dashboard:env/pkg/tour.malloy",
|
|
173
|
+
"older",
|
|
174
|
+
);
|
|
175
|
+
const fresh = new BrowserDocumentStorage();
|
|
176
|
+
expect(await fresh.getDocument(linear)).toBe("current");
|
|
177
|
+
expect(
|
|
178
|
+
localStorage.getItem(
|
|
179
|
+
"publisher:document:dashboard:env/pkg/tour.malloy",
|
|
180
|
+
),
|
|
181
|
+
).toBe("older");
|
|
182
|
+
});
|
|
81
183
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Credible Data Inc.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
|
+
import { migrateKindTypedDrafts } from "../legacy/kindTypedDrafts";
|
|
4
5
|
import {
|
|
5
6
|
DocumentNotFoundError,
|
|
6
7
|
type DocumentLocator,
|
|
@@ -16,19 +17,60 @@ const LOCAL_WORKSPACE: Workspace = {
|
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
|
-
* Every key this store writes starts with this,
|
|
20
|
-
* documents without reading everything else the
|
|
21
|
-
* (the theme mode, other libraries' state).
|
|
22
|
-
* key as a document.
|
|
20
|
+
* Every key this store writes starts with this, followed by the document's
|
|
21
|
+
* path, so it can list its own documents without reading everything else the
|
|
22
|
+
* page keeps in localStorage (the theme mode, other libraries' state).
|
|
23
23
|
*/
|
|
24
|
-
const KEY_PREFIX = "publisher:
|
|
24
|
+
const KEY_PREFIX = "publisher:report:";
|
|
25
|
+
|
|
26
|
+
/** What one key holds: the content, and the layout its last save recorded. */
|
|
27
|
+
interface Stored {
|
|
28
|
+
type: DocumentType;
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const keyOf = (path: string) => `${KEY_PREFIX}${path}`;
|
|
33
|
+
|
|
34
|
+
function read(key: string): Stored | undefined {
|
|
35
|
+
const raw = localStorage.getItem(key);
|
|
36
|
+
if (raw === null) return undefined;
|
|
37
|
+
try {
|
|
38
|
+
const stored = JSON.parse(raw) as Partial<Stored>;
|
|
39
|
+
if (
|
|
40
|
+
typeof stored.content === "string" &&
|
|
41
|
+
(stored.type === "grid" || stored.type === "linear")
|
|
42
|
+
)
|
|
43
|
+
return { type: stored.type, content: stored.content };
|
|
44
|
+
} catch {
|
|
45
|
+
// Not ours to read: treated as absent rather than as a document.
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const write = (path: string, stored: Stored) =>
|
|
51
|
+
localStorage.setItem(keyOf(path), JSON.stringify(stored));
|
|
25
52
|
|
|
26
53
|
/**
|
|
27
54
|
* A {@link DocumentStorage} in the browser's localStorage: one workspace,
|
|
28
55
|
* `Local`, private to this browser and this origin. The Console's default, and
|
|
29
56
|
* what a host uses before it has a store of its own.
|
|
57
|
+
*
|
|
58
|
+
* A document is keyed by its path alone; its layout is stored with it.
|
|
30
59
|
*/
|
|
31
60
|
export class BrowserDocumentStorage implements DocumentStorage {
|
|
61
|
+
private migrated = false;
|
|
62
|
+
|
|
63
|
+
/** Drafts saved under the old type-keyed scheme, moved once per store so they are still found. */
|
|
64
|
+
private migrate(): void {
|
|
65
|
+
if (this.migrated) return;
|
|
66
|
+
this.migrated = true;
|
|
67
|
+
migrateKindTypedDrafts(localStorage, (path, type, content) => {
|
|
68
|
+
if (read(keyOf(path)) !== undefined) return false;
|
|
69
|
+
write(path, { type, content });
|
|
70
|
+
return true;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
32
74
|
async listWorkspaces(writeableOnly: boolean): Promise<Workspace[]> {
|
|
33
75
|
void writeableOnly; // the one workspace is writeable
|
|
34
76
|
return [LOCAL_WORKSPACE];
|
|
@@ -39,34 +81,50 @@ export class BrowserDocumentStorage implements DocumentStorage {
|
|
|
39
81
|
type?: DocumentType,
|
|
40
82
|
): Promise<DocumentLocator[]> {
|
|
41
83
|
if (workspace.name !== LOCAL_WORKSPACE.name) return [];
|
|
84
|
+
this.migrate();
|
|
42
85
|
const found: DocumentLocator[] = [];
|
|
43
86
|
for (let i = 0; i < localStorage.length; i++) {
|
|
44
87
|
const key = localStorage.key(i);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
88
|
+
if (key === null || !key.startsWith(KEY_PREFIX)) continue;
|
|
89
|
+
const stored = read(key);
|
|
90
|
+
if (stored && (type === undefined || stored.type === type))
|
|
91
|
+
found.push({
|
|
92
|
+
workspace: LOCAL_WORKSPACE.name,
|
|
93
|
+
type: stored.type,
|
|
94
|
+
path: key.slice(KEY_PREFIX.length),
|
|
95
|
+
});
|
|
49
96
|
}
|
|
50
97
|
return found;
|
|
51
98
|
}
|
|
52
99
|
|
|
53
100
|
async getDocument(locator: DocumentLocator): Promise<string> {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
101
|
+
this.migrate();
|
|
102
|
+
const stored = read(keyOf(locator.path));
|
|
103
|
+
if (stored === undefined) throw missing(locator);
|
|
104
|
+
return stored.content;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async getDocumentType(
|
|
108
|
+
locator: Pick<DocumentLocator, "workspace" | "path">,
|
|
109
|
+
): Promise<DocumentType> {
|
|
110
|
+
this.migrate();
|
|
111
|
+
const stored = read(keyOf(locator.path));
|
|
112
|
+
if (stored === undefined) throw missing(locator);
|
|
113
|
+
return stored.type;
|
|
57
114
|
}
|
|
58
115
|
|
|
59
116
|
async saveDocument(
|
|
60
117
|
locator: DocumentLocator,
|
|
61
118
|
content: string,
|
|
62
119
|
): Promise<void> {
|
|
63
|
-
|
|
120
|
+
this.migrate();
|
|
121
|
+
write(locator.path, { type: locator.type, content });
|
|
64
122
|
}
|
|
65
123
|
|
|
66
124
|
async deleteDocument(locator: DocumentLocator): Promise<void> {
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
localStorage.removeItem(
|
|
125
|
+
this.migrate();
|
|
126
|
+
if (read(keyOf(locator.path)) === undefined) throw missing(locator);
|
|
127
|
+
localStorage.removeItem(keyOf(locator.path));
|
|
70
128
|
}
|
|
71
129
|
|
|
72
130
|
async moveDocument(
|
|
@@ -74,33 +132,13 @@ export class BrowserDocumentStorage implements DocumentStorage {
|
|
|
74
132
|
to: DocumentLocator,
|
|
75
133
|
): Promise<void> {
|
|
76
134
|
const content = await this.getDocument(from);
|
|
77
|
-
|
|
78
|
-
localStorage.removeItem(keyOf(from));
|
|
135
|
+
write(to.path, { type: to.type, content });
|
|
136
|
+
if (to.path !== from.path) localStorage.removeItem(keyOf(from.path));
|
|
79
137
|
}
|
|
80
138
|
}
|
|
81
139
|
|
|
82
|
-
function
|
|
83
|
-
// The type is one segment; the path may contain anything, so it goes last
|
|
84
|
-
// and is read back as "the rest".
|
|
85
|
-
return `${KEY_PREFIX}${locator.type}:${locator.path}`;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function locatorOf(key: string): DocumentLocator | undefined {
|
|
89
|
-
if (!key.startsWith(KEY_PREFIX)) return undefined;
|
|
90
|
-
const rest = key.slice(KEY_PREFIX.length);
|
|
91
|
-
const separator = rest.indexOf(":");
|
|
92
|
-
if (separator <= 0) return undefined;
|
|
93
|
-
const type = rest.slice(0, separator);
|
|
94
|
-
if (type !== "dashboard" && type !== "notebook") return undefined;
|
|
95
|
-
return {
|
|
96
|
-
workspace: LOCAL_WORKSPACE.name,
|
|
97
|
-
type,
|
|
98
|
-
path: rest.slice(separator + 1),
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function missing(locator: DocumentLocator): Error {
|
|
140
|
+
function missing(locator: Pick<DocumentLocator, "workspace" | "path">): Error {
|
|
103
141
|
return new DocumentNotFoundError(
|
|
104
|
-
`No
|
|
142
|
+
`No report at ${locator.workspace}/${locator.path}`,
|
|
105
143
|
);
|
|
106
144
|
}
|