@malloy-publisher/sdk 0.9.0 → 0.9.2
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/dist/{Dashboard-H1kJlDFo.es.js → DashboardTile-BFcxdv7R.es.js} +15918 -17760
- package/dist/DashboardTile-sg8LjUk8.cjs.js +137 -0
- package/dist/RenderedResult-B48wAjM8.cjs.js +141 -0
- package/dist/{RenderedResult-BRgIgxWh.es.js → RenderedResult-CBLHr32C.es.js} +193 -183
- package/dist/{ServerProvider-Boxrv6Ym.es.js → ServerProvider-DCV8BUWD.es.js} +529 -521
- package/dist/ServerProvider-HRqT3w1C.cjs.js +1 -0
- package/dist/builder/index.cjs.js +146 -58
- package/dist/builder/index.es.js +9076 -6479
- package/dist/builder-entry.d.ts +4 -0
- package/dist/client/api.d.ts +82 -48
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +84 -82
- package/dist/components/Dashboard/Dashboard.d.ts +8 -15
- package/dist/components/Dashboard/DashboardGrid.d.ts +23 -6
- package/dist/components/Dashboard/DashboardTile.d.ts +10 -1
- package/dist/components/Dashboard/DashboardView.d.ts +36 -0
- package/dist/components/Dashboard/TileCard.d.ts +15 -4
- package/dist/components/Dashboard/TileFilterTag.d.ts +12 -0
- package/dist/components/Dashboard/index.d.ts +3 -0
- package/dist/components/Dashboard/telemetry.d.ts +15 -3
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +8 -1
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +16 -5
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +48 -21
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -4
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +2 -10
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +2 -2
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +3 -1
- package/dist/components/DashboardBuilder/InlineMarkdown.d.ts +18 -0
- package/dist/components/DashboardBuilder/InlineText.d.ts +19 -0
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +15 -0
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +27 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +19 -7
- package/dist/components/DashboardBuilder/SourceViewPicker.d.ts +9 -0
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +7 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +14 -12
- package/dist/components/DashboardBuilder/TileMenu.d.ts +11 -3
- package/dist/components/DashboardBuilder/annotationText.d.ts +4 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +4 -0
- package/dist/components/DashboardBuilder/changedTile.d.ts +7 -0
- package/dist/components/DashboardBuilder/chartLine.d.ts +33 -0
- package/dist/components/DashboardBuilder/controls.d.ts +2 -2
- package/dist/components/DashboardBuilder/document.d.ts +42 -26
- package/dist/components/DashboardBuilder/documentSession.d.ts +100 -0
- package/dist/components/DashboardBuilder/legacyNotebook.d.ts +73 -0
- package/dist/components/DashboardBuilder/loadMalloy.d.ts +15 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -5
- package/dist/components/DashboardBuilder/malloyTree.d.ts +119 -0
- package/dist/components/DashboardBuilder/newDashboard.d.ts +3 -1
- package/dist/components/DashboardBuilder/openDraft.d.ts +10 -0
- package/dist/components/DashboardBuilder/preview.d.ts +24 -4
- package/dist/components/DashboardBuilder/readDocument.d.ts +4 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +16 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +14 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +13 -13
- package/dist/components/DashboardBuilder/spliceResult.d.ts +11 -0
- package/dist/components/DashboardBuilder/tagParse.d.ts +24 -0
- package/dist/components/DashboardBuilder/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +3 -1
- package/dist/components/DashboardBuilder/testing/inline.d.ts +4 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +89 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +9 -6
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +17 -55
- package/dist/components/DashboardBuilder/useDocumentEditor.d.ts +105 -0
- package/dist/components/DashboardBuilder/useExitGuard.d.ts +19 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +3 -3
- package/dist/components/DocumentCreate/canRetry.d.ts +6 -0
- package/dist/components/DocumentCreate/createDocument.d.ts +58 -0
- package/dist/components/DocumentCreate/documentPath.d.ts +10 -0
- package/dist/components/DocumentCreate/events.d.ts +10 -0
- package/dist/components/DocumentCreate/exportedSources.d.ts +7 -0
- package/dist/components/DocumentCreate/guards.d.ts +12 -0
- package/dist/components/DocumentCreate/index.d.ts +6 -0
- package/dist/components/DocumentCreate/newNotebook.d.ts +9 -0
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +32 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +2 -1
- package/dist/components/NarrowEditGate.d.ts +8 -0
- package/dist/components/Notebook/Notebook.d.ts +1 -1
- package/dist/components/Package/NewDocumentDialog.d.ts +33 -0
- package/dist/components/Package/Package.d.ts +1 -0
- package/dist/components/Package/documentLocation.d.ts +28 -0
- package/dist/components/Package/index.d.ts +4 -0
- package/dist/components/Package/useDocumentLocation.d.ts +12 -0
- package/dist/components/PackageSection.d.ts +2 -2
- package/dist/components/RenderedResult/RenderedResult.d.ts +2 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +8 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +3 -1
- package/dist/components/RenderedResult/resultSizing.d.ts +9 -1
- package/dist/components/ServerProvider.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +9 -0
- package/dist/components/given/GivensPanel.d.ts +2 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useNarrowScreen.d.ts +4 -0
- package/dist/hooks/useQueryResult.d.ts +2 -0
- package/dist/hooks/useSettled.d.ts +14 -0
- package/dist/index.cjs.js +23 -24
- package/dist/index.es.js +9714 -7072
- package/dist/text/index.cjs.js +1 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.es.js +6 -0
- package/dist/text-entry-BJwltZiy.cjs.js +7 -0
- package/dist/text-entry-CbbBcZl8.es.js +196 -0
- package/dist/text-entry.d.ts +2 -0
- package/dist/utils/clock.d.ts +2 -0
- package/package.json +10 -1
- package/src/builder-entry.ts +35 -0
- package/src/components/Dashboard/Dashboard.tsx +27 -278
- package/src/components/Dashboard/DashboardGrid.tsx +68 -7
- package/src/components/Dashboard/DashboardTile.spec.tsx +24 -0
- package/src/components/Dashboard/DashboardTile.tsx +31 -4
- package/src/components/Dashboard/DashboardView.spec.tsx +212 -0
- package/src/components/Dashboard/DashboardView.tsx +352 -0
- package/src/components/Dashboard/RowsDialog.tsx +1 -1
- package/src/components/Dashboard/TileCard.tsx +44 -10
- package/src/components/Dashboard/TileFilterTag.spec.tsx +73 -0
- package/src/components/Dashboard/TileFilterTag.tsx +78 -0
- package/src/components/Dashboard/defaultTileSpan.spec.ts +32 -0
- package/src/components/Dashboard/index.ts +3 -0
- package/src/components/Dashboard/telemetry.ts +16 -5
- package/src/components/DashboardBuilder/AddTileDialog.spec.tsx +88 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +137 -111
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +85 -27
- package/src/components/DashboardBuilder/ChartPicker.render.spec.tsx +25 -0
- package/src/components/DashboardBuilder/ChartPicker.spec.ts +77 -0
- package/src/components/DashboardBuilder/ChartPicker.tsx +153 -0
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +205 -0
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +192 -0
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +329 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +363 -0
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +194 -0
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +157 -0
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +124 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +103 -78
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +177 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +610 -315
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +58 -8
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +191 -0
- package/src/components/DashboardBuilder/DashboardEditor.filterTag.spec.tsx +162 -0
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +316 -0
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +56 -10
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +5 -22
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +96 -14
- package/src/components/DashboardBuilder/DashboardEditor.tsx +482 -332
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +25 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +5 -24
- package/src/components/DashboardBuilder/DrillDialog.tsx +1 -1
- package/src/components/DashboardBuilder/FilterDialog.tsx +10 -3
- package/src/components/DashboardBuilder/FilterStrip.tsx +26 -4
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +184 -0
- package/src/components/DashboardBuilder/InlineText.tsx +106 -0
- package/src/components/DashboardBuilder/NotebookEditor.tsx +44 -0
- package/src/components/DashboardBuilder/SaveNotice.tsx +113 -0
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +87 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +225 -67
- package/src/components/DashboardBuilder/SourceViewPicker.tsx +122 -0
- package/src/components/DashboardBuilder/TextTileBody.tsx +28 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +89 -115
- package/src/components/DashboardBuilder/TileMenu.tsx +168 -90
- package/src/components/DashboardBuilder/annotationText.spec.ts +33 -0
- package/src/components/DashboardBuilder/annotationText.ts +17 -0
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +248 -0
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +41 -0
- package/src/components/DashboardBuilder/catalog.aggregate.spec.ts +49 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +2 -0
- package/src/components/DashboardBuilder/catalog.ts +61 -21
- package/src/components/DashboardBuilder/changedTile.spec.ts +46 -0
- package/src/components/DashboardBuilder/changedTile.ts +28 -0
- package/src/components/DashboardBuilder/chartLine.spec.ts +180 -0
- package/src/components/DashboardBuilder/chartLine.ts +121 -0
- package/src/components/DashboardBuilder/controls.spec.ts +21 -10
- package/src/components/DashboardBuilder/controls.ts +22 -8
- package/src/components/DashboardBuilder/document.ts +53 -5
- package/src/components/DashboardBuilder/documentSession.spec.ts +209 -0
- package/src/components/DashboardBuilder/documentSession.ts +257 -0
- package/src/components/DashboardBuilder/emptyStart.spec.ts +131 -0
- package/src/components/DashboardBuilder/invariants.spec.ts +6 -2
- package/src/components/DashboardBuilder/legacyNotebook.chart.spec.ts +77 -0
- package/src/components/DashboardBuilder/legacyNotebook.convert.spec.ts +630 -0
- package/src/components/DashboardBuilder/legacyNotebook.read.spec.ts +338 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1117 -0
- package/src/components/DashboardBuilder/loadMalloy.spec.ts +80 -0
- package/src/components/DashboardBuilder/loadMalloy.ts +39 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +48 -0
- package/src/components/DashboardBuilder/malloyText.ts +181 -27
- package/src/components/DashboardBuilder/malloyTree.ts +155 -7
- package/src/components/DashboardBuilder/newDashboard.spec.ts +46 -2
- package/src/components/DashboardBuilder/newDashboard.ts +30 -3
- package/src/components/DashboardBuilder/openDraft.ts +52 -0
- package/src/components/DashboardBuilder/preview.shapes.spec.ts +75 -0
- package/src/components/DashboardBuilder/preview.spec.ts +159 -12
- package/src/components/DashboardBuilder/preview.ts +83 -9
- package/src/components/DashboardBuilder/readDocument.spec.ts +139 -27
- package/src/components/DashboardBuilder/readDocument.ts +130 -44
- package/src/components/DashboardBuilder/readForEditor.spec.ts +80 -0
- package/src/components/DashboardBuilder/readForEditor.ts +47 -0
- package/src/components/DashboardBuilder/scannerShapes.spec.ts +14 -13
- package/src/components/DashboardBuilder/sortable.spec.ts +65 -0
- package/src/components/DashboardBuilder/sortable.tsx +2 -12
- package/src/components/DashboardBuilder/spliceDocument.chart.spec.ts +340 -0
- package/src/components/DashboardBuilder/spliceDocument.imports.spec.ts +167 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +229 -94
- package/src/components/DashboardBuilder/spliceDocument.ts +762 -130
- package/src/components/DashboardBuilder/spliceResult.ts +15 -0
- package/src/components/DashboardBuilder/statementExtent.spec.ts +33 -30
- package/src/components/DashboardBuilder/tagParse.spec.ts +149 -0
- package/src/components/DashboardBuilder/tagParse.ts +103 -0
- package/src/components/DashboardBuilder/telemetry.ts +47 -0
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +197 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +16 -1
- package/src/components/DashboardBuilder/testing/inline.ts +25 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +718 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +335 -0
- package/src/components/DashboardBuilder/useBuilderSession.ts +292 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +65 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.spec.tsx +60 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +36 -10
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +16 -13
- package/src/components/DashboardBuilder/useDashboardEditor.ts +54 -181
- package/src/components/DashboardBuilder/useDocumentEditor.spec.ts +565 -0
- package/src/components/DashboardBuilder/useDocumentEditor.ts +399 -0
- package/src/components/DashboardBuilder/useExitGuard.spec.ts +159 -0
- package/src/components/DashboardBuilder/useExitGuard.ts +89 -0
- package/src/components/DashboardBuilder/useFilterForm.existing.spec.tsx +41 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +24 -2
- package/src/components/DashboardBuilder/useFilterForm.ts +41 -13
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +28 -5
- package/src/components/DashboardBuilder/useTileReorder.ts +5 -7
- package/src/components/DocumentCreate/canRetry.spec.ts +32 -0
- package/src/components/DocumentCreate/canRetry.ts +19 -0
- package/src/components/DocumentCreate/createDocument.spec.ts +310 -0
- package/src/components/DocumentCreate/createDocument.ts +159 -0
- package/src/components/DocumentCreate/documentPath.ts +40 -0
- package/src/components/DocumentCreate/events.ts +15 -0
- package/src/components/DocumentCreate/exportedSources.ts +25 -0
- package/src/components/DocumentCreate/guards.ts +45 -0
- package/src/components/DocumentCreate/index.ts +27 -0
- package/src/components/DocumentCreate/newNotebook.spec.ts +156 -0
- package/src/components/DocumentCreate/newNotebook.ts +44 -0
- package/src/components/DocumentCreate/useDocumentChoices.spec.tsx +138 -0
- package/src/components/DocumentCreate/useDocumentChoices.ts +113 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +2 -1
- package/src/components/Model/ModelExplorer.spec.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -4
- package/src/components/NarrowEditGate.spec.tsx +73 -0
- package/src/components/NarrowEditGate.tsx +29 -0
- package/src/components/Notebook/Notebook.layout.spec.tsx +94 -0
- package/src/components/Notebook/Notebook.tsx +66 -27
- package/src/components/Package/NewDocumentDialog.spec.tsx +749 -0
- package/src/components/Package/NewDocumentDialog.tsx +401 -0
- package/src/components/Package/Package.artifacts.spec.tsx +190 -0
- package/src/components/Package/Package.create.spec.tsx +380 -0
- package/src/components/Package/Package.notebooks.spec.tsx +18 -0
- package/src/components/Package/Package.tsx +366 -171
- package/src/components/Package/documentLocation.spec.ts +81 -0
- package/src/components/Package/documentLocation.ts +55 -0
- package/src/components/Package/index.ts +13 -0
- package/src/components/Package/useDocumentLocation.ts +59 -0
- package/src/components/PackageSection.tsx +2 -2
- package/src/components/RenderedResult/RenderedResult.tsx +18 -1
- package/src/components/RenderedResult/ResultContainer.tsx +44 -11
- package/src/components/RenderedResult/ResultPanel.tsx +4 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +68 -0
- package/src/components/RenderedResult/resultSizing.ts +14 -3
- package/src/components/ServerProvider.tsx +2 -1
- package/src/components/UnsavedChangesDialog.spec.tsx +70 -0
- package/src/components/UnsavedChangesDialog.tsx +49 -0
- package/src/components/given/GivensPanel.spec.tsx +6 -6
- package/src/components/given/GivensPanel.tsx +3 -3
- package/src/components/index.ts +2 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useNarrowScreen.ts +21 -0
- package/src/hooks/useQueryResult.ts +16 -0
- package/src/hooks/useSettled.spec.ts +41 -0
- package/src/hooks/useSettled.ts +27 -0
- package/src/mainEntry.spec.ts +145 -0
- package/src/text-entry.ts +12 -0
- package/src/textEntry.spec.ts +118 -0
- package/src/utils/clock.spec.ts +12 -0
- package/src/utils/clock.ts +6 -0
- package/vite.config.ts +4 -0
- package/dist/Dashboard-ChyylkTD.cjs.js +0 -136
- package/dist/RenderedResult-AJPMUkAD.cjs.js +0 -135
- package/dist/ServerProvider-CXrOKD6g.cjs.js +0 -1
- package/dist/components/DashboardBuilder/useTileResize.d.ts +0 -29
- package/dist/components/Package/NewDashboardDialog.d.ts +0 -18
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +0 -121
- package/src/components/DashboardBuilder/useTileResize.ts +0 -110
- package/src/components/Package/NewDashboardDialog.spec.tsx +0 -129
- package/src/components/Package/NewDashboardDialog.tsx +0 -265
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { QueryClient, QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import { Workspace } from '../DocumentStorage';
|
|
3
|
+
import { ApiClients } from '../ServerProvider';
|
|
4
|
+
/** Where a host's Save lands. */
|
|
5
|
+
export type SavesTo = "package" | "browser" | "host";
|
|
6
|
+
/**
|
|
7
|
+
* The record when one declares itself, and otherwise the first writeable
|
|
8
|
+
* workspace. Pass every workspace, not only the writeable ones: a reader who
|
|
9
|
+
* cannot write to the record still has to be shown the record.
|
|
10
|
+
*/
|
|
11
|
+
export declare function chooseWorkspace(all: readonly Workspace[]): Workspace | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Where Save goes, and which writer takes it, or `undefined` for no Save.
|
|
14
|
+
*
|
|
15
|
+
* `authoritative` wins outright rather than breaking a tie: a host whose store
|
|
16
|
+
* is the record may well sit on a server that reports itself writable, and
|
|
17
|
+
* writing the package there would edit a deploy of the record instead of the
|
|
18
|
+
* record.
|
|
19
|
+
*/
|
|
20
|
+
export declare function saveTarget({ authoritative, mutable, versionId, canStore, readFailed, }: {
|
|
21
|
+
authoritative: boolean;
|
|
22
|
+
mutable: boolean;
|
|
23
|
+
versionId?: string;
|
|
24
|
+
/** The host keeps documents and the chosen workspace takes writes. */
|
|
25
|
+
canStore: boolean;
|
|
26
|
+
/** The host's copy could not be read. */
|
|
27
|
+
readFailed: boolean;
|
|
28
|
+
}): {
|
|
29
|
+
savesTo: SavesTo;
|
|
30
|
+
pinnedPackageSave: boolean;
|
|
31
|
+
writer: "storage" | "package" | undefined;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The `expectedHash` a package write carries: the server's own hash after this
|
|
35
|
+
* editor's last write, else the hash of the package file the editor opened on.
|
|
36
|
+
* Never the latest fetch's, which may already hold someone else's change.
|
|
37
|
+
*/
|
|
38
|
+
export declare function expectedHashFor(savedHash: string | undefined, base: string | undefined): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* What the toolbar says about where Save goes, in the backend's own words
|
|
41
|
+
* wherever it has any: a workspace carries a `description` precisely so the
|
|
42
|
+
* editor does not have to guess, and "this browser" is one host's answer
|
|
43
|
+
* rather than the interface's.
|
|
44
|
+
*/
|
|
45
|
+
export declare function saveCaption({ authoritative, mutable, pinnedPackageSave, workspace, readFailure, versionId, }: {
|
|
46
|
+
authoritative: boolean;
|
|
47
|
+
mutable: boolean;
|
|
48
|
+
pinnedPackageSave: boolean;
|
|
49
|
+
workspace?: Workspace;
|
|
50
|
+
readFailure?: string;
|
|
51
|
+
versionId?: string;
|
|
52
|
+
}): string;
|
|
53
|
+
/** What a storage backend said went wrong, for a reader who has to act on it. */
|
|
54
|
+
export declare function storageErrorMessage(error: unknown): string;
|
|
55
|
+
/** The server's own reason for a refused write, when it gave one. */
|
|
56
|
+
export declare function apiErrorMessage(error: unknown): string;
|
|
57
|
+
/** A query family a package write marks stale. */
|
|
58
|
+
export interface Invalidation {
|
|
59
|
+
queryKey: QueryKey;
|
|
60
|
+
/** `"none"` marks the family stale without refetching it. */
|
|
61
|
+
refetchType?: "none";
|
|
62
|
+
/** Hold the write's result until the refetch lands. */
|
|
63
|
+
wait?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Writes a package file against `expectedHash` and returns the server's hash
|
|
67
|
+
* of what it wrote. A refused write invalidates `invalidateOnError`, since it
|
|
68
|
+
* usually means the file moved, and throws the server's own reason.
|
|
69
|
+
* `afterWrite` runs once the write has landed and before the invalidations, so
|
|
70
|
+
* the caller's bookkeeping is in place when a refetch arrives.
|
|
71
|
+
*/
|
|
72
|
+
export declare function writePackageFile({ apiClients, queryClient, environmentName, packageName, modelPath, source, expectedHash, invalidateOnError, invalidate, afterWrite, }: {
|
|
73
|
+
apiClients: ApiClients;
|
|
74
|
+
queryClient: QueryClient;
|
|
75
|
+
environmentName: string;
|
|
76
|
+
packageName: string;
|
|
77
|
+
modelPath: string;
|
|
78
|
+
source: string;
|
|
79
|
+
expectedHash: string;
|
|
80
|
+
invalidateOnError: readonly QueryKey[];
|
|
81
|
+
invalidate: readonly Invalidation[];
|
|
82
|
+
afterWrite?: (contentHash: string) => Promise<void> | void;
|
|
83
|
+
}): Promise<string>;
|
|
84
|
+
/** The host workspace that took a save or its undo, named on the event; a package save was taken by none. */
|
|
85
|
+
export declare function withWorkspace<E extends {
|
|
86
|
+
type: string;
|
|
87
|
+
}>(event: E, workspace: string | undefined): E;
|
|
88
|
+
/** The environment, package and version an editor was asked for, from either prop form; a render body must not throw, so a URI `parseResourceUri` rejects reads as naming neither. */
|
|
89
|
+
export declare function resolveEditorTarget(props: {
|
|
90
|
+
resourceUri: string;
|
|
91
|
+
} | {
|
|
92
|
+
environmentName: string;
|
|
93
|
+
packageName: string;
|
|
94
|
+
}): {
|
|
95
|
+
environmentName: string;
|
|
96
|
+
packageName: string;
|
|
97
|
+
versionId: string | undefined;
|
|
98
|
+
/** False when a resource URI did not name both an environment and a package. */
|
|
99
|
+
namesBoth: boolean;
|
|
100
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Span } from './malloyTree';
|
|
2
|
+
export type { Span };
|
|
3
|
+
/** A `# <chart>` line the chart rule recognizes, whole line including its newline. */
|
|
4
|
+
export interface ChartLineSpan {
|
|
5
|
+
span: Span;
|
|
6
|
+
/** The line less its newline. */
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
/** The chart tag lines of a query cell. */
|
|
10
|
+
export interface QueryChart {
|
|
11
|
+
lines: ChartLineSpan[];
|
|
12
|
+
/** A `#` line that names a chart tag but is not one the rule recognizes, kept byte for byte. */
|
|
13
|
+
unmodelled?: string;
|
|
14
|
+
/** Where a new chart line goes: the start of the line holding the statement's code. */
|
|
15
|
+
insertAt: number;
|
|
16
|
+
}
|
|
17
|
+
export interface NotebookSourceCell {
|
|
18
|
+
kind: "markdown" | "query" | "definition";
|
|
19
|
+
/** The movable chunk: from the first line of its tag/prose/caption/comment block to the end of the statement's last line (incl. newline). */
|
|
20
|
+
span: Span;
|
|
21
|
+
/** markdown cells: the prose; query cells: the attached header prose, if any. */
|
|
22
|
+
markdown?: string;
|
|
23
|
+
/** Statement cells: the attached `(markdown)`/`(text)` notes and `"` captions, each a whole note token run. */
|
|
24
|
+
prose?: Span[];
|
|
25
|
+
/** Query cells only. */
|
|
26
|
+
chart?: QueryChart;
|
|
27
|
+
/** Stable id for React keys and history; its index in the read. */
|
|
28
|
+
id: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A notebook's layout. `header` starts at 0; the cells follow in file order
|
|
32
|
+
* without overlapping it or each other, and every byte between two spans (or
|
|
33
|
+
* after the last) is a gap the writer keeps as it found it.
|
|
34
|
+
*/
|
|
35
|
+
export interface NotebookSource {
|
|
36
|
+
text: string;
|
|
37
|
+
header: Span;
|
|
38
|
+
cells: NotebookSourceCell[];
|
|
39
|
+
}
|
|
40
|
+
export type NotebookSourceResult = {
|
|
41
|
+
ok: true;
|
|
42
|
+
source: NotebookSource;
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
refused: string;
|
|
46
|
+
line?: number;
|
|
47
|
+
};
|
|
48
|
+
export declare const notebookSourceRefused: (r: NotebookSourceResult) => r is Extract<NotebookSourceResult, {
|
|
49
|
+
ok: false;
|
|
50
|
+
}>;
|
|
51
|
+
/** A notebook's layout, or why it cannot be edited; a refusal's `line` is 1-based, while lines inside are 0-based. */
|
|
52
|
+
export declare function readNotebookSource(text: string): Promise<NotebookSourceResult>;
|
|
53
|
+
export type LegacyConversion = {
|
|
54
|
+
ok: true;
|
|
55
|
+
text: string;
|
|
56
|
+
tiles: number;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
refused: string;
|
|
60
|
+
line?: number;
|
|
61
|
+
};
|
|
62
|
+
export declare const conversionRefused: (r: LegacyConversion) => r is Extract<LegacyConversion, {
|
|
63
|
+
ok: false;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Rewrite a cell-format notebook (`run:` cells and prose cells) as a layout
|
|
67
|
+
* notebook: the same file with a `tiles=[…]` list, each prose cell a
|
|
68
|
+
* `##|(markdown)` block, and each `run:` a view in a `<source>_tiles`
|
|
69
|
+
* extension. Text outside the cells is carried over as written.
|
|
70
|
+
*
|
|
71
|
+
* PURE: text in, text out. The caller keeps the original to hand back on Undo.
|
|
72
|
+
*/
|
|
73
|
+
export declare function convertLegacyNotebook(text: string): Promise<LegacyConversion>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Malloy = typeof import("@malloydata/malloy");
|
|
2
|
+
type MalloyTag = typeof import("@malloydata/malloy-tag");
|
|
3
|
+
type QueryBuilder = typeof import("@malloydata/malloy-query-builder");
|
|
4
|
+
export declare const unwrapMalloy: (ns: Malloy) => Malloy;
|
|
5
|
+
export declare const unwrapMalloyTag: (ns: MalloyTag) => MalloyTag;
|
|
6
|
+
export declare const unwrapQueryBuilder: (ns: QueryBuilder) => QueryBuilder;
|
|
7
|
+
/**
|
|
8
|
+
* Imported dynamically, never statically: `builder-entry.ts` installs the
|
|
9
|
+
* `process.env` shim the parser's dependencies read at module scope, and a
|
|
10
|
+
* static import would be evaluated before that shim runs.
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadMalloy(): Promise<Malloy>;
|
|
13
|
+
export declare function loadMalloyTag(): Promise<MalloyTag>;
|
|
14
|
+
export declare function loadQueryBuilder(): Promise<QueryBuilder>;
|
|
15
|
+
export {};
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
/** A file's lines, whatever its line endings: a CRLF line otherwise keeps a `\r` that a `$` anchor trips on. */
|
|
2
|
+
export declare const splitSourceLines: (source: string) => string[];
|
|
1
3
|
export declare const isIdentifier: (text: string) => boolean;
|
|
2
|
-
/**
|
|
3
|
-
export declare const
|
|
4
|
+
/** A name that can stand bare as a source, view or tile name: identifier-shaped and never reserved. */
|
|
5
|
+
export declare const isBareName: (text: string) => boolean;
|
|
6
|
+
/** A name that can stand bare as a given name: also not a statement keyword, since `NAME ::` is not a statement. */
|
|
7
|
+
export declare const isStrictName: (text: string) => boolean;
|
|
8
|
+
/** A filter field as written after `where:`: a lone reserved name is back-quoted; a dotted path (`.year` is reserved too) or an expression stays verbatim. */
|
|
9
|
+
export declare const malloyPath: (path: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Whether a `##` note or `##|` block sets `artifact` as a top-level property, anywhere among its
|
|
12
|
+
* properties, as the tag parser reads it: not inside a string, a nested `{…}` or `[…]`, or a `#`
|
|
13
|
+
* comment, and not as a value (`title=artifact`) or a dotted path's tail. The server's rule too.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setsArtifactProperty(note: string): boolean;
|
|
4
16
|
/**
|
|
5
17
|
* A note's markdown route, by Malloy's prefix rule: the first whitespace-delimited token is
|
|
6
18
|
* `#`/`##`, an optional `|`, and `(markdown)` or its `<>`, `[]`, `{}` twin. `#(markdown)hi` has
|
|
@@ -29,8 +41,25 @@ export declare function blockLines(lines: string[]): Set<number>;
|
|
|
29
41
|
* A line inside a block comment (`skip`) or inside another block is no annotation.
|
|
30
42
|
*/
|
|
31
43
|
export declare function markdownLines(lines: string[], skip?: (line: number) => boolean): Set<number>;
|
|
32
|
-
/**
|
|
44
|
+
/** Where the model-level artifact tag sits, written as one `## artifact { … }` line or as a `##|` … `|##` block. */
|
|
45
|
+
export interface ArtifactTag {
|
|
46
|
+
/** The tag's first line: the `## artifact` line, or a block's `##|` opener. */
|
|
47
|
+
from: number;
|
|
48
|
+
/** The last line the tag occupies: the same line when single, else the `|##` closer. */
|
|
49
|
+
to: number;
|
|
50
|
+
block: boolean;
|
|
51
|
+
/** The tag as written: its line, or a block's lines from the opener up to, not including, the closer. */
|
|
52
|
+
text: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function artifactTag(lines: string[]): ArtifactTag | undefined;
|
|
55
|
+
/** Whether `artifact { … }` is the tag's first property, the one spelling the builder's tag rewrites can edit. */
|
|
56
|
+
export declare const artifactLeads: (tagText: string) => boolean;
|
|
57
|
+
/** Why a tag the server serves is not opened when `artifact` is not its first property. */
|
|
58
|
+
export declare const ARTIFACT_NOT_FIRST = "The `artifact` property is not the first on its tag, so the builder cannot rewrite the tag without risking the properties before it. Move `artifact { \u2026 }` first on the tag to edit this file here.";
|
|
59
|
+
/** The line carrying the model-level artifact tag (a block's opener), or -1. */
|
|
33
60
|
export declare const artifactLine: (lines: string[]) => number;
|
|
61
|
+
/** A tag's text as the annotation parser takes it: one `#` annotation, whatever the spelling. */
|
|
62
|
+
export declare const tagAnnotation: (tagText: string) => string;
|
|
34
63
|
/**
|
|
35
64
|
* The lines a dashboard's description is read from, by the server's rule: the
|
|
36
65
|
* notes above the artifact tag, or, when those carry no prose, the notes below
|
|
@@ -48,8 +77,17 @@ export declare function descriptionNotes(lines: string[]): {
|
|
|
48
77
|
inBlock: boolean;
|
|
49
78
|
text?: string;
|
|
50
79
|
};
|
|
51
|
-
/**
|
|
52
|
-
export declare
|
|
80
|
+
/** A text tile's name: a bare word, as the server reads a `tiles=[…]` entry. */
|
|
81
|
+
export declare const TEXT_TILE_NAME: RegExp;
|
|
82
|
+
/**
|
|
83
|
+
* A floating `##|(markdown)` / `##|(text)` opener line: its route, and what follows the route.
|
|
84
|
+
* `name` is that text when it is a lone bare word; any other text on the opener is body.
|
|
85
|
+
*/
|
|
86
|
+
export declare function textBlockOpener(line: string): {
|
|
87
|
+
route: "markdown" | "text";
|
|
88
|
+
rest: string;
|
|
89
|
+
name?: string;
|
|
90
|
+
} | undefined;
|
|
53
91
|
/** A tile expression's steps: `orders -> by_brand + { limit: 2 }`. */
|
|
54
92
|
export interface TileSteps {
|
|
55
93
|
source: string;
|
|
@@ -62,3 +100,5 @@ export interface TileSteps {
|
|
|
62
100
|
* Undefined for anything else: an inline stage, or a longer pipeline.
|
|
63
101
|
*/
|
|
64
102
|
export declare function tileSteps(expression: string | undefined): TileSteps | undefined;
|
|
103
|
+
/** The inverse of {@link malloyPath}: a field that is exactly one back-quoted identifier is read as the plain name; anything else is verbatim. */
|
|
104
|
+
export declare const readPath: (path: string) => string;
|
|
@@ -136,6 +136,16 @@ export interface TreeImport extends Positioned {
|
|
|
136
136
|
names?: string[];
|
|
137
137
|
statement: Span;
|
|
138
138
|
}
|
|
139
|
+
/** A floating `##|(markdown) [name]` … `|##` block, which a dashboard reads as a text tile's body. */
|
|
140
|
+
export interface TreeTextBlock extends Positioned {
|
|
141
|
+
/** Absent when the opener has no name, or more than one word after the route. */
|
|
142
|
+
name?: string;
|
|
143
|
+
route: "markdown" | "text";
|
|
144
|
+
/** Text on the opener line (unless it is only the name), then the body lines; no trailing newline. */
|
|
145
|
+
body: string;
|
|
146
|
+
/** From the opener's line start through the closer's newline: the whole-line extent a writer replaces or removes. */
|
|
147
|
+
span: Span;
|
|
148
|
+
}
|
|
139
149
|
export interface ParsedMalloy {
|
|
140
150
|
text: string;
|
|
141
151
|
/** 0-based line -> offset of its first character. */
|
|
@@ -143,6 +153,8 @@ export interface ParsedMalloy {
|
|
|
143
153
|
imports: TreeImport[];
|
|
144
154
|
sources: TreeSource[];
|
|
145
155
|
givens: TreeGiven[];
|
|
156
|
+
/** The closed floating `(markdown)` / `(text)` blocks, in file order. */
|
|
157
|
+
textBlocks: TreeTextBlock[];
|
|
146
158
|
/** The comment token on `line`, if the line ends with one. */
|
|
147
159
|
trailingComment(line: number): Span | undefined;
|
|
148
160
|
/**
|
|
@@ -177,6 +189,68 @@ export type ParseResult = {
|
|
|
177
189
|
parsed: ParsedMalloy;
|
|
178
190
|
} | ParseRefusal;
|
|
179
191
|
export declare const parseRefused: (r: ParseResult) => r is ParseRefusal;
|
|
192
|
+
export interface TokenStream {
|
|
193
|
+
tokenSource?: {
|
|
194
|
+
vocabulary?: {
|
|
195
|
+
getSymbolicName(type: number): string | undefined;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
getTokens?(): Array<{
|
|
199
|
+
type: number;
|
|
200
|
+
startIndex: number;
|
|
201
|
+
stopIndex: number;
|
|
202
|
+
}>;
|
|
203
|
+
}
|
|
204
|
+
export type Ctx = Record<string, unknown> & {
|
|
205
|
+
ruleIndex?: number;
|
|
206
|
+
childCount?: number;
|
|
207
|
+
getChild(i: number): Ctx;
|
|
208
|
+
start?: {
|
|
209
|
+
startIndex: number;
|
|
210
|
+
line: number;
|
|
211
|
+
};
|
|
212
|
+
stop?: {
|
|
213
|
+
stopIndex: number;
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
/** A rule context we can take a range from; terminals and empties are not. */
|
|
217
|
+
export declare const isRule: (c: Ctx | undefined) => boolean;
|
|
218
|
+
export declare class Reader {
|
|
219
|
+
readonly text: string;
|
|
220
|
+
private readonly map;
|
|
221
|
+
readonly lineStarts: number[];
|
|
222
|
+
/**
|
|
223
|
+
* Lines that are comment rather than code, filled in from the lexer before
|
|
224
|
+
* anything is read. A block comment's own text is prose: a line inside one
|
|
225
|
+
* that happens to start with `#` is not an annotation, and reading it as one
|
|
226
|
+
* makes the writer rewrite a line inside a comment.
|
|
227
|
+
*/
|
|
228
|
+
commentLines: ReadonlySet<number>;
|
|
229
|
+
/** `(markdown)` annotation lines, whose body can start with `#` without being a tag. */
|
|
230
|
+
proseLines: ReadonlySet<number>;
|
|
231
|
+
/** The `#|` blocks with a closer, as [opener line, closer line]; a comment's lines open none. */
|
|
232
|
+
blocks: [number, number][];
|
|
233
|
+
constructor(text: string);
|
|
234
|
+
/**
|
|
235
|
+
* The span a context covers, or `undefined` when it covers nothing we can
|
|
236
|
+
* trust. Empty rule contexts report inverted or whole-file ranges without
|
|
237
|
+
* throwing, so every span is checked rather than assumed.
|
|
238
|
+
*/
|
|
239
|
+
span(c: Ctx | undefined): Span | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* The span of a TERMINAL node — a keyword or punctuation. A terminal has no
|
|
242
|
+
* rule range, only the token it stands for, and asking `span` for one
|
|
243
|
+
* silently yields nothing.
|
|
244
|
+
*/
|
|
245
|
+
terminal(node: unknown): Span | undefined;
|
|
246
|
+
/** A parser code-point index as a JS string offset. */
|
|
247
|
+
utf16(codePoint: number): number | undefined;
|
|
248
|
+
text_(c: Ctx | undefined): string | undefined;
|
|
249
|
+
line(offset: number): number;
|
|
250
|
+
positioned(c: Ctx | undefined): Positioned | undefined;
|
|
251
|
+
/** The whitespace a line begins with, which anything inserted matches. */
|
|
252
|
+
indentAt(offset: number): string;
|
|
253
|
+
}
|
|
180
254
|
/**
|
|
181
255
|
* Parse `text`, or refuse.
|
|
182
256
|
*
|
|
@@ -193,6 +267,14 @@ export declare function parseMalloy(text: string): Promise<ParseResult>;
|
|
|
193
267
|
export interface MalloyProblem {
|
|
194
268
|
code?: string;
|
|
195
269
|
message?: string;
|
|
270
|
+
/** 0-based. */
|
|
271
|
+
at?: {
|
|
272
|
+
range?: {
|
|
273
|
+
start?: {
|
|
274
|
+
line?: number;
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
};
|
|
196
278
|
}
|
|
197
279
|
/** One parse of one file, stopped at the parse step. */
|
|
198
280
|
export interface Translation {
|
|
@@ -214,3 +296,40 @@ export interface Translation {
|
|
|
214
296
|
* resolved -- so callers see every syntax error and none of the semantic ones.
|
|
215
297
|
*/
|
|
216
298
|
export declare function translate(text: string, url: string): Promise<Translation>;
|
|
299
|
+
/**
|
|
300
|
+
* The comments, taken from the LEXER's own tokens rather than from a scan for
|
|
301
|
+
* `//`: a `//` inside a string literal is not a comment, and every scan here
|
|
302
|
+
* that had to know that got it wrong at least once.
|
|
303
|
+
*
|
|
304
|
+
* BOTH token kinds, because Malloy has two and spells a comment three ways:
|
|
305
|
+
* `//` and `--` lex as `COMMENT_TO_EOL`, `/* … *\/` as `BLOCK_COMMENT`. A
|
|
306
|
+
* filter on the first name alone left every block comment out of this index,
|
|
307
|
+
* so it was invisible to `commentIn` -- and a writer asking that before it
|
|
308
|
+
* deleted a range was told there was nothing there to lose.
|
|
309
|
+
*
|
|
310
|
+
* A comment alone on its line belongs to the block above a declaration; one
|
|
311
|
+
* that follows code is a trailing comment, and anything appended to that line
|
|
312
|
+
* has to go before it.
|
|
313
|
+
*/
|
|
314
|
+
export declare function commentIndex(r: Reader, tokenStream: TokenStream): {
|
|
315
|
+
trailing: Map<number, Span>;
|
|
316
|
+
lines: Set<number>;
|
|
317
|
+
all: Span[];
|
|
318
|
+
};
|
|
319
|
+
/** One `tiles=[…]` entry, exactly as written, with where it sits in the line. */
|
|
320
|
+
export interface TileEntry {
|
|
321
|
+
text: string;
|
|
322
|
+
span: Span;
|
|
323
|
+
}
|
|
324
|
+
export interface TileList {
|
|
325
|
+
/** Offsets of `[` and the matching `]` in the line. */
|
|
326
|
+
open: number;
|
|
327
|
+
close: number;
|
|
328
|
+
entries: TileEntry[];
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* The `tiles=[…]` list of a one-line `## artifact { … }` tag, as written: quoted run expressions
|
|
332
|
+
* and `name { kind=text … }` entries alike. Undefined when the tag has no list or it never closes.
|
|
333
|
+
* Strings and nested braces are skipped, so a title containing `tiles=[` or a `]` is not the list.
|
|
334
|
+
*/
|
|
335
|
+
export declare function readTileList(line: string): TileList | undefined;
|
|
@@ -14,4 +14,6 @@ export interface NewDashboard {
|
|
|
14
14
|
}
|
|
15
15
|
/** `Sales by region` → `sales-by-region`: the file name, and so the slug. */
|
|
16
16
|
export declare function slugFor(title: string): string;
|
|
17
|
-
|
|
17
|
+
/** Why this dashboard cannot be written as a file, or undefined when it can. */
|
|
18
|
+
export declare function newDashboardProblem({ title, modelPath, source, view, }: NewDashboard): string | undefined;
|
|
19
|
+
export declare function newDashboardSource(dashboard: NewDashboard): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MutableRefObject, Context } from 'react';
|
|
2
|
+
/** Where an inline field tells the builder it holds text that is not in the document yet. */
|
|
3
|
+
export interface OpenDraftSink {
|
|
4
|
+
setDirty: (dirty: boolean) => void;
|
|
5
|
+
/** Holds a function that commits the open draft; true when it did, false when the draft was refused. */
|
|
6
|
+
commitRef: MutableRefObject<(() => boolean) | undefined>;
|
|
7
|
+
}
|
|
8
|
+
export declare const OpenDraftContext: Context<OpenDraftSink>;
|
|
9
|
+
/** Reports an open field's draft as unsaved while `dirty`, and lets a save commit it first. */
|
|
10
|
+
export declare function useReportOpenDraft(dirty: boolean, commit: () => boolean): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given } from '../../client';
|
|
2
2
|
import { GivenValue } from '../../hooks/givenValue';
|
|
3
|
-
import { DashboardDocument,
|
|
3
|
+
import { DashboardDocument, QueryTile } from './document';
|
|
4
4
|
/**
|
|
5
5
|
* What a reader would see if the DOCUMENT were the file: the controls, and
|
|
6
6
|
* each tile's query — so the builder's live view follows an edit the moment it
|
|
@@ -26,16 +26,34 @@ import { DashboardDocument, DashboardTile } from './document';
|
|
|
26
26
|
* suggest is gated by, for one).
|
|
27
27
|
*/
|
|
28
28
|
export declare function previewGivens(document: DashboardDocument, modelSpecs: readonly Given[]): Given[];
|
|
29
|
+
/** A tile expression as the server keys it, so `a->b` and `a -> b` match. */
|
|
30
|
+
export declare function tileExpressionKey(expression: string): string;
|
|
29
31
|
/** A tile's query as the document has it, and the givens it sends. */
|
|
30
32
|
export interface PreviewTileQuery {
|
|
31
33
|
/** A run expression, without `run:` — what `DashboardTile.tile` takes. */
|
|
32
34
|
expression: string;
|
|
33
35
|
/**
|
|
34
|
-
* The
|
|
35
|
-
*
|
|
36
|
+
* The chart line the tile's wrapper carries, to sit above the `run:`. A
|
|
37
|
+
* reference tile runs its base view, which has never seen the wrapper, so
|
|
38
|
+
* without it the tile would draw the view's own chart whatever the picker
|
|
39
|
+
* says. An inline or opaque tile runs the SAVED view, wrapper line and all,
|
|
40
|
+
* so Default there carries the all-negating line: the saved line is what
|
|
41
|
+
* Default removes. Absent when a reference tile's wrapper adds none.
|
|
42
|
+
*/
|
|
43
|
+
annotation?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The givens this tile binds, its extension reads, or its served tile
|
|
46
|
+
* reads that the server can take, for narrowing the request. Undefined for a tile whose bindings live in the model, where the
|
|
36
47
|
* document cannot know them: send the whole row, as the reader does.
|
|
37
48
|
*/
|
|
38
49
|
givenNames: string[] | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Every given this tile's preview answers to, runnable or not, for saying
|
|
52
|
+
* which controls it ignores. Undefined when nothing can say: a tile the
|
|
53
|
+
* served file did not resolve (inherited, or not saved yet) whose document
|
|
54
|
+
* side reads no given either.
|
|
55
|
+
*/
|
|
56
|
+
reads: string[] | undefined;
|
|
39
57
|
}
|
|
40
58
|
/**
|
|
41
59
|
* A tile's query with the DOCUMENT's bindings, run on the dashboard's own
|
|
@@ -74,4 +92,6 @@ export interface PreviewTileQuery {
|
|
|
74
92
|
* without its bindings, which this builder deliberately does not do: it
|
|
75
93
|
* splices, and never writes a view's body out from the document.
|
|
76
94
|
*/
|
|
77
|
-
export declare function previewTileQuery(document: DashboardDocument, tile:
|
|
95
|
+
export declare function previewTileQuery(document: DashboardDocument, tile: QueryTile, runnable: ReadonlySet<string>, values?: ReadonlyMap<string, GivenValue>,
|
|
96
|
+
/** What the served file's compiled tile reads (`DashboardTile.givenNames`), when it has this tile. */
|
|
97
|
+
served?: readonly string[]): PreviewTileQuery;
|
|
@@ -29,6 +29,8 @@ export interface ReadFailure {
|
|
|
29
29
|
reason: string;
|
|
30
30
|
/** 1-based, for a message that can point at the line. */
|
|
31
31
|
line?: number;
|
|
32
|
+
/** The file is a `kind=notebook` in the run-cell format, which `convertLegacyNotebook` turns into a layout notebook. */
|
|
33
|
+
legacyNotebook?: true;
|
|
32
34
|
}
|
|
33
35
|
export type ReadResult = {
|
|
34
36
|
ok: true;
|
|
@@ -99,5 +101,6 @@ type ParseTags = (lines: string[]) => {
|
|
|
99
101
|
* Either way the `#` tags above a declaration are its control contract.
|
|
100
102
|
*/
|
|
101
103
|
export declare function localGivens(parsed: ParsedMalloy, lines: string[], parse: ParseTags): LocalGiven[] | undefined;
|
|
102
|
-
|
|
104
|
+
/** Refuses rather than throws: `Tag.text()` throws on a malformed date literal such as `@2024-13-01`, and dropping the value would lose it on the next save. */
|
|
105
|
+
export declare function readDashboardDocument(sourceText: string, modelPath?: string): Promise<ReadResult>;
|
|
103
106
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DashboardDocument } from './document';
|
|
2
|
+
/** A file opened for editing: its document, and the conversion it is the result of when the file is a cell-format notebook. */
|
|
3
|
+
export type EditorOpen = {
|
|
4
|
+
ok: true;
|
|
5
|
+
document: DashboardDocument;
|
|
6
|
+
/** `from` is the text on disk, `to` the layout text it converts to. */
|
|
7
|
+
conversion?: {
|
|
8
|
+
from: string;
|
|
9
|
+
to: string;
|
|
10
|
+
};
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
reason: string;
|
|
14
|
+
};
|
|
15
|
+
/** Read `text` for the builder, converting a cell-format notebook rather than refusing it. */
|
|
16
|
+
export declare function readForEditor(text: string, modelPath?: string): Promise<EditorOpen>;
|
|
@@ -3,6 +3,20 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { PluginDescriptor, Plugin } from '@dnd-kit/abstract';
|
|
4
4
|
/** The type of a gap: the empty end of a row, offered as a drop target. */
|
|
5
5
|
export declare const GAP_TYPE = "gap";
|
|
6
|
+
/**
|
|
7
|
+
* The sensors: the library's own, with one addition.
|
|
8
|
+
*
|
|
9
|
+
* `activatorElements`: the whole tile starts a pointer drag,
|
|
10
|
+
* not only the grip. A 22px corner that appears on hover is not a target a
|
|
11
|
+
* reader finds; the whole card is. The grip stays the `handle`, which is what
|
|
12
|
+
* gives it keyboard focus and the screen-reader instructions — and, by the
|
|
13
|
+
* library's own rule, a press on the handle drags at once while a press
|
|
14
|
+
* anywhere else on the card waits for a short hold or a few pixels of travel,
|
|
15
|
+
* so a click inside a tile stays a click. Those thresholds, and the check that
|
|
16
|
+
* a press on a button or a link is never a drag, are the defaults: they are
|
|
17
|
+
* what every surface built on this library feels like, and the hand-tuned
|
|
18
|
+
* versions this replaced were most of why the gesture felt unfamiliar.
|
|
19
|
+
*/
|
|
6
20
|
export declare const builderSensors: ( PluginDescriptor<any, Plugin<any, PointerSensorOptions>, typeof PointerSensor> | typeof KeyboardSensor)[];
|
|
7
21
|
interface TileSortableHandles {
|
|
8
22
|
/** The tile's element: what is dragged, and what a drop lands on. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DashboardDocument, DashboardTile } from './document';
|
|
2
|
+
import { spliceFailed, SpliceFailure, SpliceResult } from './spliceResult';
|
|
2
3
|
/**
|
|
3
4
|
* The syntax errors Malloy's own parser reports for `text`, as a multiset of
|
|
4
5
|
* messages.
|
|
@@ -35,24 +36,15 @@ export declare function syntaxErrors(text: string): Promise<string[]>;
|
|
|
35
36
|
* ADDED or REMOVED: a new `view:` inside the extension of the source it reads
|
|
36
37
|
* (or a new extension, when the file imports that source by name), a removed
|
|
37
38
|
* one deleted with its `#` tags. Those moves are the one place the file cannot
|
|
38
|
-
* say who owns the comment beside a declaration, so the
|
|
39
|
-
*
|
|
39
|
+
* say who owns the comment beside a declaration, so the `//` comments are left
|
|
40
|
+
* where they were and the author can read the change back with View change.
|
|
40
41
|
*
|
|
41
42
|
* A given is different from a tile in exactly the way that matters there: the
|
|
42
43
|
* `#` tags above its declaration are its control contract and have no other
|
|
43
44
|
* owner, so removing the declaration can take them with it, and a `//` comment
|
|
44
45
|
* in the same block is left where it is.
|
|
45
46
|
*/
|
|
46
|
-
export
|
|
47
|
-
ok: false;
|
|
48
|
-
reason: string;
|
|
49
|
-
}
|
|
50
|
-
export type SpliceResult = {
|
|
51
|
-
ok: true;
|
|
52
|
-
source: string;
|
|
53
|
-
} | SpliceFailure;
|
|
54
|
-
/** Narrow to the failure arm; see {@link readFailed} for why a guard. */
|
|
55
|
-
export declare const spliceFailed: (result: SpliceResult) => result is SpliceFailure;
|
|
47
|
+
export { spliceFailed, type SpliceFailure, type SpliceResult };
|
|
56
48
|
/**
|
|
57
49
|
* One tile's identity TO THE FILE, ignoring presentation and position — but
|
|
58
50
|
* not its declaration: a tile redeclared from another view is a different tile
|
|
@@ -62,4 +54,12 @@ export declare const spliceFailed: (result: SpliceResult) => result is SpliceFai
|
|
|
62
54
|
* rewrite declarations?" wants THIS key.
|
|
63
55
|
*/
|
|
64
56
|
export declare const tileFileKey: (t: DashboardTile) => string;
|
|
65
|
-
|
|
57
|
+
/** Why a text tile's markdown cannot be written into a block, or undefined when it can: the writer's refusals, for an editor to show live. */
|
|
58
|
+
export declare function markdownProblem(markdown: string): string | undefined;
|
|
59
|
+
export interface SpliceOptions {
|
|
60
|
+
/** Lets `requested.kind` differ from the file's: the one edit that switches a dashboard to a notebook or back. */
|
|
61
|
+
changeKind?: boolean;
|
|
62
|
+
/** The file's path within the package; a dashboard under `notebooks/` is tagged `kind=dashboard` rather than left untagged. */
|
|
63
|
+
modelPath?: string;
|
|
64
|
+
}
|
|
65
|
+
export declare function spliceDashboardDocument(sourceText: string, requested: DashboardDocument, options?: SpliceOptions): Promise<SpliceResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** What a writer hands back: the patched file, or why it refused to write one. */
|
|
2
|
+
export interface SpliceFailure {
|
|
3
|
+
ok: false;
|
|
4
|
+
reason: string;
|
|
5
|
+
}
|
|
6
|
+
export type SpliceResult = {
|
|
7
|
+
ok: true;
|
|
8
|
+
source: string;
|
|
9
|
+
} | SpliceFailure;
|
|
10
|
+
/** Narrow to the failure arm; see `readFailed` in `readDocument.ts` for why a guard. */
|
|
11
|
+
export declare const spliceFailed: (result: SpliceResult) => result is SpliceFailure;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A MOTLY parse as `parseAnnotation` returns it; only the reads this file makes. */
|
|
2
|
+
type Parsed<T> = {
|
|
3
|
+
tag: T;
|
|
4
|
+
log: Array<{
|
|
5
|
+
message: string;
|
|
6
|
+
}>;
|
|
7
|
+
};
|
|
8
|
+
type ParseAnnotation<T> = (lines: string[]) => Parsed<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Quote each bare filter literal (`f'US'`) so MOTLY reads it as a string, as
|
|
11
|
+
* the server does. The rewritten line is never spliced into the file; a changed
|
|
12
|
+
* `givens { … }` block is re-emitted, quoted, from the values parsed out of it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function quoteFilterLiterals(annotation: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* `parseAnnotation` that rescues bare filter literals. Parse-first: only a line
|
|
17
|
+
* MOTLY rejects is rewritten, and only kept if the rewrite parses, so a valid
|
|
18
|
+
* tag is never altered. `errors` are the parse messages that remain.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseTagLines<T>(parseAnnotation: ParseAnnotation<T>, lines: string[]): {
|
|
21
|
+
tag: T;
|
|
22
|
+
errors: string[];
|
|
23
|
+
};
|
|
24
|
+
export {};
|