@malloy-publisher/sdk 0.9.10 → 0.9.11
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/RenderedResult-BlNoIiSi.cjs.js +153 -0
- package/dist/{RenderedResult-Dp1Qdajz.es.js → RenderedResult-Cmx8sX8d.es.js} +102 -102
- package/dist/ServerProvider-BOgiW8MX.cjs.js +1 -0
- package/dist/{ServerProvider-CQy4jVYK.es.js → ServerProvider-azXLkk1q.es.js} +619 -586
- package/dist/builder/index.cjs.js +78 -130
- package/dist/builder/index.es.js +7493 -6769
- package/dist/builder-entry.d.ts +3 -0
- package/dist/client/api.d.ts +26 -22
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/AppDialog.d.ts +9 -1
- package/dist/components/Dashboard/DashboardGrid.d.ts +14 -15
- package/dist/components/Dashboard/DashboardTile.d.ts +8 -1
- package/dist/components/Dashboard/DashboardView.d.ts +22 -34
- package/dist/components/Dashboard/TileCard.d.ts +10 -3
- package/dist/components/Dashboard/useStuck.d.ts +15 -7
- package/dist/components/DocumentCreate/useDocumentChoices.d.ts +6 -0
- package/dist/components/Package/PackageProblems.d.ts +14 -0
- package/dist/components/RemoveBadge.d.ts +40 -0
- package/dist/components/Report/Report.d.ts +13 -4
- package/dist/components/Report/ReportPage.d.ts +60 -0
- package/dist/components/Report/layoutRules.d.ts +32 -0
- package/dist/components/Report/reportQuery.d.ts +30 -0
- package/dist/components/Report/telemetry.d.ts +0 -2
- package/dist/components/ReportBuilder/AddTileDialog.d.ts +22 -3
- package/dist/components/ReportBuilder/BuilderBar.d.ts +17 -0
- package/dist/components/ReportBuilder/BuilderDialogs.d.ts +7 -6
- package/dist/components/ReportBuilder/BuilderGrid.d.ts +10 -4
- package/dist/components/ReportBuilder/BuilderHeader.d.ts +4 -7
- package/dist/components/ReportBuilder/BuilderToolbar.d.ts +88 -0
- package/dist/components/ReportBuilder/DrillDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/EditorSurface.d.ts +7 -9
- package/dist/components/ReportBuilder/FilterDialog.d.ts +3 -1
- package/dist/components/ReportBuilder/FilterStrip.d.ts +30 -8
- package/dist/components/ReportBuilder/InlineMarkdown.d.ts +4 -4
- package/dist/components/ReportBuilder/ReportBuilder.d.ts +49 -12
- package/dist/components/ReportBuilder/ReportEditor.d.ts +53 -3
- package/dist/components/ReportBuilder/TextTileBody.d.ts +2 -5
- package/dist/components/ReportBuilder/TileFrame.d.ts +10 -4
- package/dist/components/ReportBuilder/TileMenu.d.ts +12 -9
- package/dist/components/ReportBuilder/ViewPicker.d.ts +53 -0
- package/dist/components/ReportBuilder/addTileToDocument.d.ts +24 -3
- package/dist/components/ReportBuilder/builderControls.d.ts +60 -0
- package/dist/components/ReportBuilder/catalog.d.ts +2 -4
- package/dist/components/ReportBuilder/inlineEdit.d.ts +9 -10
- package/dist/components/ReportBuilder/localGiven.d.ts +12 -0
- package/dist/components/ReportBuilder/preview.d.ts +17 -2
- package/dist/components/ReportBuilder/readDocument.d.ts +0 -2
- package/dist/components/ReportBuilder/readForEditor.d.ts +2 -7
- package/dist/components/ReportBuilder/reportTag.d.ts +11 -1
- package/dist/components/ReportBuilder/sortable.d.ts +4 -3
- package/dist/components/ReportBuilder/testing/inline.d.ts +5 -1
- package/dist/components/ReportBuilder/useBuilderSelection.d.ts +0 -1
- package/dist/components/ReportBuilder/useBuilderSession.d.ts +21 -12
- package/dist/components/ReportBuilder/useDocumentEditor.d.ts +2 -6
- package/dist/components/ReportBuilder/useExitGuard.d.ts +3 -0
- package/dist/components/ReportBuilder/useFilterForm.d.ts +3 -1
- package/dist/components/ReportBuilder/useOpenedDocument.d.ts +0 -4
- package/dist/components/ReportBuilder/useReportDraft.d.ts +66 -0
- package/dist/components/ReportBuilder/useReportEditor.d.ts +0 -9
- package/dist/components/ReportBuilder/useTileEditing.d.ts +6 -3
- package/dist/components/ReportBuilder/viewAnnotations.d.ts +9 -0
- package/dist/components/ReportBuilder/widthLabel.d.ts +6 -0
- package/dist/components/ServerProvider.d.ts +9 -0
- package/dist/components/controlTokens.d.ts +45 -0
- package/dist/components/drill/markDrillableCells.d.ts +1 -1
- package/dist/components/given/FilterButton.d.ts +35 -0
- package/dist/components/given/GivensPanel.d.ts +2 -1
- package/dist/components/given/filterEditing.d.ts +54 -0
- package/dist/components/given/filterSummary.d.ts +9 -0
- package/dist/components/given/paramCodec.d.ts +11 -0
- package/dist/components/given/required.d.ts +25 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/legacy/index.d.ts +1 -1
- package/dist/components/{Report/CellReport.d.ts → legacy/malloynb/CellRunnerView.d.ts} +9 -17
- package/dist/components/legacy/{MalloynbCells.d.ts → malloynb/MalloynbCells.d.ts} +3 -3
- package/dist/components/legacy/{Notebook.d.ts → malloynb/Notebook.d.ts} +1 -1
- package/dist/components/{Notebook → legacy/malloynb}/NotebookCell.d.ts +3 -3
- package/dist/components/legacy/malloynb/cellKind.d.ts +5 -0
- package/dist/components/{Notebook → legacy/malloynb}/types.d.ts +1 -1
- package/dist/components/styles.d.ts +0 -2
- package/dist/hooks/useQueryResult.d.ts +7 -0
- package/dist/index.cjs.js +16 -19
- package/dist/index.es.js +8324 -7769
- package/dist/theme/ThemeContext.d.ts +8 -1
- package/dist/theme/classes.d.ts +49 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/ui.d.ts +75 -0
- package/dist/{useCompiledDocument-BMPDvdFx.es.js → useCompiledDocument-7j5cBjQd.es.js} +8669 -7851
- package/dist/useCompiledDocument-B21sVbb4.cjs.js +141 -0
- package/package.json +2 -2
- package/src/builder-entry.ts +9 -0
- package/src/components/AppDialog.tsx +23 -0
- package/src/components/Dashboard/DashboardGrid.tsx +39 -17
- package/src/components/Dashboard/DashboardTile.tsx +19 -2
- package/src/components/Dashboard/DashboardView.spec.tsx +216 -15
- package/src/components/Dashboard/DashboardView.tsx +137 -155
- package/src/components/Dashboard/RowsDialog.tsx +1 -2
- package/src/components/Dashboard/TileCard.tsx +28 -10
- package/src/components/Dashboard/defaultTileSpan.spec.ts +24 -0
- package/src/components/Dashboard/useStuck.ts +28 -17
- package/src/components/DocumentCreate/useDocumentChoices.ts +19 -2
- package/src/components/Package/NewDocumentDialog.spec.tsx +76 -59
- package/src/components/Package/NewDocumentDialog.tsx +383 -119
- package/src/components/Package/Package.artifacts.spec.tsx +1 -1
- package/src/components/Package/Package.create.spec.tsx +7 -6
- package/src/components/Package/Package.tsx +10 -7
- package/src/components/Package/PackageProblems.spec.tsx +41 -0
- package/src/components/Package/PackageProblems.tsx +95 -0
- package/src/components/Prose.tsx +12 -7
- package/src/components/RemoveBadge.tsx +94 -0
- package/src/components/RenderedResult/RenderedResult.tsx +5 -9
- package/src/components/RenderedResult/ResultPanel.tsx +59 -3
- package/src/components/Report/Report.spec.tsx +50 -32
- package/src/components/Report/Report.telemetry.spec.tsx +0 -45
- package/src/components/Report/Report.tsx +45 -77
- package/src/components/Report/ReportPage.tsx +168 -0
- package/src/components/Report/layoutRules.spec.ts +35 -0
- package/src/components/Report/layoutRules.ts +55 -0
- package/src/components/Report/reportQuery.ts +53 -0
- package/src/components/Report/telemetry.ts +0 -2
- package/src/components/ReportBuilder/AddTileDialog.spec.tsx +76 -41
- package/src/components/ReportBuilder/AddTileDialog.tsx +368 -133
- package/src/components/ReportBuilder/BuilderBar.tsx +599 -0
- package/src/components/ReportBuilder/BuilderDialogs.tsx +28 -39
- package/src/components/ReportBuilder/BuilderGrid.tsx +31 -29
- package/src/components/ReportBuilder/BuilderHeader.tsx +63 -75
- package/src/components/ReportBuilder/BuilderToolbar.tsx +95 -9
- package/src/components/ReportBuilder/DrillDialog.tsx +240 -128
- package/src/components/ReportBuilder/EditorSurface.tsx +345 -69
- package/src/components/ReportBuilder/FilterDialog.tsx +516 -166
- package/src/components/ReportBuilder/FilterStrip.tsx +130 -151
- package/src/components/ReportBuilder/InlineMarkdown.tsx +71 -45
- package/src/components/ReportBuilder/ReportBuilder.charts.spec.tsx +35 -40
- package/src/components/ReportBuilder/ReportBuilder.controls.spec.tsx +491 -0
- package/src/components/ReportBuilder/ReportBuilder.exit.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportBuilder.inline.spec.tsx +13 -15
- package/src/components/ReportBuilder/ReportBuilder.notebook.spec.tsx +27 -118
- package/src/components/ReportBuilder/ReportBuilder.openDraft.spec.tsx +12 -5
- package/src/components/ReportBuilder/ReportBuilder.sources.spec.tsx +2 -10
- package/src/components/ReportBuilder/ReportBuilder.spec.tsx +37 -31
- package/src/components/ReportBuilder/ReportBuilder.textTiles.spec.tsx +22 -15
- package/src/components/ReportBuilder/ReportBuilder.tsx +292 -117
- package/src/components/ReportBuilder/ReportEditor.emptyStart.spec.tsx +2 -1
- package/src/components/ReportBuilder/ReportEditor.modelFilters.spec.tsx +312 -0
- package/src/components/ReportBuilder/ReportEditor.notebook.spec.tsx +26 -75
- package/src/components/ReportBuilder/ReportEditor.package.spec.tsx +6 -2
- package/src/components/ReportBuilder/ReportEditor.resourceUri.spec.tsx +3 -2
- package/src/components/ReportBuilder/ReportEditor.spec.tsx +2 -4
- package/src/components/ReportBuilder/ReportEditor.textSource.spec.tsx +93 -13
- package/src/components/ReportBuilder/ReportEditor.tsx +104 -14
- package/src/components/ReportBuilder/TextTileBody.tsx +6 -7
- package/src/components/ReportBuilder/TileFrame.tsx +212 -75
- package/src/components/ReportBuilder/TileMenu.tsx +241 -140
- package/src/components/ReportBuilder/ViewPicker.tsx +349 -0
- package/src/components/ReportBuilder/addTile.compile.spec.ts +1 -1
- package/src/components/ReportBuilder/addTileToDocument.spec.ts +102 -3
- package/src/components/ReportBuilder/addTileToDocument.ts +122 -25
- package/src/components/ReportBuilder/builderControls.ts +164 -0
- package/src/components/ReportBuilder/builderReport.ts +1 -2
- package/src/components/ReportBuilder/catalog.ts +10 -26
- package/src/components/ReportBuilder/inlineEdit.tsx +22 -54
- package/src/components/ReportBuilder/localGiven.ts +56 -0
- package/src/components/ReportBuilder/preview.spec.ts +125 -5
- package/src/components/ReportBuilder/preview.ts +60 -44
- package/src/components/ReportBuilder/readDocument.spec.ts +16 -22
- package/src/components/ReportBuilder/readDocument.ts +14 -11
- package/src/components/ReportBuilder/readForEditor.spec.ts +12 -41
- package/src/components/ReportBuilder/readForEditor.ts +4 -26
- package/src/components/ReportBuilder/reportTag.ts +28 -7
- package/src/components/ReportBuilder/sortable.tsx +15 -7
- package/src/components/ReportBuilder/spliceDocument.imports.spec.ts +1 -1
- package/src/components/ReportBuilder/tagParse.spec.ts +0 -40
- package/src/components/ReportBuilder/testing/inline.ts +25 -5
- package/src/components/ReportBuilder/testing/reportLayoutParity.json +13 -8
- package/src/components/ReportBuilder/textTiles.spec.ts +7 -6
- package/src/components/ReportBuilder/useBuilderSelection.ts +35 -0
- package/src/components/ReportBuilder/useBuilderSession.spec.ts +2 -2
- package/src/components/ReportBuilder/useBuilderSession.ts +21 -13
- package/src/components/ReportBuilder/useDocumentEditor.spec.ts +0 -58
- package/src/components/ReportBuilder/useDocumentEditor.ts +3 -16
- package/src/components/ReportBuilder/useEditorCatalog.spec.tsx +26 -0
- package/src/components/ReportBuilder/useEditorCatalog.ts +7 -2
- package/src/components/ReportBuilder/useExitGuard.ts +16 -0
- package/src/components/ReportBuilder/useFilterForm.spec.tsx +17 -0
- package/src/components/ReportBuilder/useFilterForm.ts +5 -1
- package/src/components/ReportBuilder/useOpenedDocument.ts +0 -2
- package/src/components/ReportBuilder/useReportDraft.spec.ts +149 -0
- package/src/components/ReportBuilder/useReportDraft.ts +292 -0
- package/src/components/ReportBuilder/useReportEditor.ts +3 -12
- package/src/components/ReportBuilder/useSaveChannel.ts +0 -1
- package/src/components/ReportBuilder/useTileEditing.ts +43 -12
- package/src/components/ReportBuilder/viewAnnotations.ts +29 -0
- package/src/components/ReportBuilder/widthLabel.spec.ts +25 -0
- package/src/components/ReportBuilder/widthLabel.ts +26 -0
- package/src/components/ServerProvider.tsx +11 -0
- package/src/components/controlTokens.ts +47 -0
- package/src/components/drill/markDrillableCells.ts +2 -1
- package/src/components/given/FilterButton.spec.tsx +143 -0
- package/src/components/given/FilterButton.tsx +478 -0
- package/src/components/given/GivenInput.spec.tsx +47 -0
- package/src/components/given/GivenInput.tsx +20 -2
- package/src/components/given/GivensPanel.spec.tsx +11 -3
- package/src/components/given/GivensPanel.tsx +45 -44
- package/src/components/given/filterEditing.ts +60 -0
- package/src/components/given/filterSummary.spec.ts +108 -0
- package/src/components/given/filterSummary.ts +109 -0
- package/src/components/given/paramCodec.ts +1 -1
- package/src/components/given/required.spec.ts +60 -0
- package/src/components/given/required.ts +78 -0
- package/src/components/index.ts +9 -0
- package/src/components/legacy/Dashboard.spec.tsx +3 -1
- package/src/components/legacy/index.ts +1 -1
- package/src/components/{Report/CellReport.spec.tsx → legacy/malloynb/CellRunnerView.spec.tsx} +53 -57
- package/src/components/{Report/CellReport.tsx → legacy/malloynb/CellRunnerView.tsx} +122 -136
- package/src/components/legacy/{MalloynbCells.tsx → malloynb/MalloynbCells.tsx} +6 -6
- package/src/components/legacy/{Notebook.layout.spec.tsx → malloynb/Notebook.layout.spec.tsx} +16 -7
- package/src/components/legacy/malloynb/Notebook.served.spec.tsx +84 -0
- package/src/components/legacy/{Notebook.spec.tsx → malloynb/Notebook.spec.tsx} +5 -3
- package/src/components/legacy/{Notebook.tsx → malloynb/Notebook.tsx} +9 -7
- package/src/components/{Notebook → legacy/malloynb}/NotebookCell.tsx +70 -150
- package/src/components/legacy/malloynb/cellKind.spec.ts +33 -0
- package/src/components/legacy/malloynb/cellKind.ts +24 -0
- package/src/components/{Notebook → legacy/malloynb}/types.ts +1 -1
- package/src/components/styles.ts +0 -18
- package/src/hooks/useGivensState.ts +7 -3
- package/src/hooks/useQueryResult.placeholder.spec.ts +44 -0
- package/src/hooks/useQueryResult.ts +26 -1
- package/src/theme/ThemeContext.tsx +21 -1
- package/src/theme/classes.ts +52 -0
- package/src/theme/index.ts +8 -0
- package/src/theme/resolveTheme.ts +3 -0
- package/src/theme/types.ts +7 -0
- package/src/theme/ui.spec.tsx +91 -0
- package/src/theme/ui.ts +115 -0
- package/dist/RenderedResult-BcgYjkZ0.cjs.js +0 -153
- package/dist/ServerProvider-B0dUY8be.cjs.js +0 -1
- package/dist/components/Notebook/cellKind.d.ts +0 -20
- package/dist/components/Report/LinearReport.d.ts +0 -18
- package/dist/components/ReportBuilder/SourceViewPicker.d.ts +0 -9
- package/dist/components/ReportBuilder/legacyNotebook.d.ts +0 -73
- package/dist/components/ReportBuilder/useConversionConfirm.d.ts +0 -20
- package/dist/useCompiledDocument-UY28ITET.cjs.js +0 -141
- package/src/components/Notebook/cellKind.spec.ts +0 -199
- package/src/components/Notebook/cellKind.ts +0 -74
- package/src/components/Report/LinearReport.tsx +0 -71
- package/src/components/ReportBuilder/SourceViewPicker.tsx +0 -122
- package/src/components/ReportBuilder/legacyNotebook.chart.spec.ts +0 -77
- package/src/components/ReportBuilder/legacyNotebook.convert.spec.ts +0 -626
- package/src/components/ReportBuilder/legacyNotebook.read.spec.ts +0 -338
- package/src/components/ReportBuilder/legacyNotebook.ts +0 -1122
- package/src/components/ReportBuilder/useConversionConfirm.ts +0 -55
- package/src/components/legacy/Notebook.served.spec.tsx +0 -183
- /package/dist/components/{Notebook → legacy/malloynb}/runPlan.d.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.spec.ts +0 -0
- /package/src/components/{Notebook → legacy/malloynb}/runPlan.ts +0 -0
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import { describe, expect, it } from "bun:test";
|
|
5
|
-
import {
|
|
6
|
-
cellCaption,
|
|
7
|
-
cellRuns,
|
|
8
|
-
definitionSummary,
|
|
9
|
-
stripProse,
|
|
10
|
-
} from "./cellKind";
|
|
11
|
-
|
|
12
|
-
describe("cellRuns", () => {
|
|
13
|
-
// DEPRECATED FEATURE COVERAGE — delete together with
|
|
14
|
-
// `.malloynb` notebooks (see RELEASE_NOTES deprecations).
|
|
15
|
-
describe("deprecated: .malloynb notebooks", () => {
|
|
16
|
-
it("runs a .malloynb code cell and skips its markdown", () => {
|
|
17
|
-
expect(cellRuns({ type: "code" })).toBe(true);
|
|
18
|
-
expect(cellRuns({ type: "markdown" })).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("runs only a query cell of a served notebook", () => {
|
|
23
|
-
expect(cellRuns({ type: "code", kind: "query" })).toBe(true);
|
|
24
|
-
expect(cellRuns({ type: "code", kind: "definition" })).toBe(false);
|
|
25
|
-
expect(cellRuns({ type: "markdown", kind: "markdown" })).toBe(false);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("cellCaption", () => {
|
|
30
|
-
it("prefers the caption the server sent", () => {
|
|
31
|
-
expect(
|
|
32
|
-
cellCaption({ text: '#" From the text\nrun: q', caption: "Served" }),
|
|
33
|
-
).toBe("Served");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('falls back to the #" lines of the tag block above the run', () => {
|
|
37
|
-
expect(
|
|
38
|
-
cellCaption({
|
|
39
|
-
text: '#" Revenue by month\n# bar_chart\nrun: sales -> by_month',
|
|
40
|
-
}),
|
|
41
|
-
).toBe("Revenue by month");
|
|
42
|
-
expect(
|
|
43
|
-
cellCaption({ text: '# bar_chart\n#" First\n#" second\nrun: q' }),
|
|
44
|
-
).toBe("First second");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('ignores a #" past the tag block, and reads past a // comment', () => {
|
|
48
|
-
expect(
|
|
49
|
-
cellCaption({ text: 'run: q -> {\n#" not a caption\n select: a }' }),
|
|
50
|
-
).toBeUndefined();
|
|
51
|
-
expect(cellCaption({ text: '// why\n#" Shown\nrun: q' })).toBe("Shown");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("does not read a caption out of the prose lines the server named", () => {
|
|
55
|
-
expect(
|
|
56
|
-
cellCaption({
|
|
57
|
-
text: '#|(markdown)\n#" not a caption\n|#\nrun: q',
|
|
58
|
-
proseLines: [[0, 2]],
|
|
59
|
-
}),
|
|
60
|
-
).toBeUndefined();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("is undefined when there is no caption", () => {
|
|
64
|
-
expect(cellCaption({ text: "# bar_chart\nrun: q" })).toBeUndefined();
|
|
65
|
-
expect(cellCaption({ text: "" })).toBeUndefined();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe("definitionSummary", () => {
|
|
70
|
-
it("names the statement kind and what it defines", () => {
|
|
71
|
-
expect(
|
|
72
|
-
definitionSummary({ text: "source: sales is orders extend {\n}" }),
|
|
73
|
-
).toBe("source: sales");
|
|
74
|
-
expect(definitionSummary({ text: "query: top is sales -> q" })).toBe(
|
|
75
|
-
"query: top",
|
|
76
|
-
);
|
|
77
|
-
expect(
|
|
78
|
-
definitionSummary({
|
|
79
|
-
text: '# label="Region"\ngiven: REGION :: filter<string>',
|
|
80
|
-
}),
|
|
81
|
-
).toBe("given: REGION");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("says only import for an import, whatever it brings in", () => {
|
|
85
|
-
expect(
|
|
86
|
-
definitionSummary({ text: 'import { a, b } from "./m.malloy"' }),
|
|
87
|
-
).toBe("import");
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("skips the prose lines the server named", () => {
|
|
91
|
-
expect(
|
|
92
|
-
definitionSummary({
|
|
93
|
-
text: "#|(markdown)\nThe orders source.\n|#\nsource: o is t",
|
|
94
|
-
proseLines: [[0, 2]],
|
|
95
|
-
}),
|
|
96
|
-
).toBe("source: o");
|
|
97
|
-
expect(
|
|
98
|
-
definitionSummary({
|
|
99
|
-
text: "#|(markdown)\nsource: not this\n|#\nsource: o is t",
|
|
100
|
-
proseLines: [[0, 2]],
|
|
101
|
-
}),
|
|
102
|
-
).toBe("source: o");
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("falls back to the first line for a statement it does not recognize", () => {
|
|
106
|
-
expect(definitionSummary({ text: "export { a }" })).toBe("export");
|
|
107
|
-
expect(definitionSummary({ text: "// note\nmystery thing" })).toBe(
|
|
108
|
-
"mystery thing",
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe("stripProse", () => {
|
|
114
|
-
it("removes exactly the lines the server named, and nothing else", () => {
|
|
115
|
-
expect(
|
|
116
|
-
stripProse({
|
|
117
|
-
text: '#|(markdown)\nBody\n|#\n#" Caption\n#(markdown) note\n# bar_chart\nrun: q',
|
|
118
|
-
proseLines: [
|
|
119
|
-
[0, 2],
|
|
120
|
-
[4, 4],
|
|
121
|
-
],
|
|
122
|
-
}),
|
|
123
|
-
).toBe('#" Caption\n# bar_chart\nrun: q');
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("keeps a ## line the server did not name", () => {
|
|
127
|
-
expect(
|
|
128
|
-
stripProse({ text: "## kept\nrun: q", proseLines: [[1, 1]] }),
|
|
129
|
-
).toBe("## kept");
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("does not guess at prose in a nested note the server left out", () => {
|
|
133
|
-
expect(
|
|
134
|
-
stripProse({
|
|
135
|
-
text: "#(markdown) lead\nsource: s is a extend {\n #(markdown) about v\n view: v is x\n}",
|
|
136
|
-
proseLines: [[0, 0]],
|
|
137
|
-
}),
|
|
138
|
-
).toBe(
|
|
139
|
-
"source: s is a extend {\n #(markdown) about v\n view: v is x\n}",
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("without ranges, drops the ## lines as the released viewer did", () => {
|
|
144
|
-
expect(
|
|
145
|
-
stripProse({ text: "## title\n ## indented\nrun: q\n#(markdown) x" }),
|
|
146
|
-
).toBe("run: q\n#(markdown) x");
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// DEPRECATED FEATURE COVERAGE — delete together with
|
|
150
|
-
// `.malloynb` notebooks (see RELEASE_NOTES deprecations).
|
|
151
|
-
describe("deprecated: .malloynb notebooks", () => {
|
|
152
|
-
it("without ranges, drops a .malloynb ##! line exactly as the released code did", () => {
|
|
153
|
-
expect(
|
|
154
|
-
stripProse({ text: "##! experimental.parameters\nrun: q" }),
|
|
155
|
-
).toBe("run: q");
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("without ranges, leaves (markdown) lines alone", () => {
|
|
160
|
-
const cell = '#(markdown) note\n#|(markdown)\nbody\n|#\n#" c\nrun: q';
|
|
161
|
-
expect(stripProse({ text: cell })).toBe(cell);
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
describe("a served cell trusts only the server", () => {
|
|
166
|
-
it("keeps a ## line inside a multi-line string when it has no prose", () => {
|
|
167
|
-
const text = 'run: duckdb.sql("""\n## not prose\nselect 1""")';
|
|
168
|
-
expect(stripProse({ text, proseLines: [], codeLine: 0 })).toBe(text);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it("shows no caption the server did not send", () => {
|
|
172
|
-
for (const text of [
|
|
173
|
-
'#"x\nrun: q',
|
|
174
|
-
'#"\u00a0nbsp\nrun: q',
|
|
175
|
-
'#|\nlabel="a"\n#" hidden\n|#\nrun: q',
|
|
176
|
-
]) {
|
|
177
|
-
expect(cellCaption({ text, proseLines: [], codeLine: 0 })).toBe(
|
|
178
|
-
undefined,
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("labels a definition by the line the server points at", () => {
|
|
184
|
-
expect(
|
|
185
|
-
definitionSummary({
|
|
186
|
-
text: '#|"\nRegion to filter by\n|#\ngiven: REGION :: string is "x"',
|
|
187
|
-
proseLines: [],
|
|
188
|
-
codeLine: 3,
|
|
189
|
-
}),
|
|
190
|
-
).toBe("given: REGION");
|
|
191
|
-
expect(
|
|
192
|
-
definitionSummary({
|
|
193
|
-
text: '#|\nlabel="Orders"\n|#\nsource: s is a',
|
|
194
|
-
proseLines: [],
|
|
195
|
-
codeLine: 3,
|
|
196
|
-
}),
|
|
197
|
-
).toBe("source: s");
|
|
198
|
-
});
|
|
199
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import type { NotebookCell } from "../../client";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Whether the viewer sends a cell to the server to run. A served notebook's
|
|
8
|
-
* definition cell is `type: code` too, so `type` alone would execute it.
|
|
9
|
-
*/
|
|
10
|
-
export function cellRuns(cell: Pick<NotebookCell, "type" | "kind">): boolean {
|
|
11
|
-
return cell.kind ? cell.kind === "query" : cell.type === "code";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type CellLines = Pick<NotebookCell, "text" | "proseLines" | "codeLine">;
|
|
15
|
-
|
|
16
|
-
/** Only a served `.malloy` cell carries `proseLines`, `[]` included; a `.malloynb` or an older server sends none. */
|
|
17
|
-
const isServed = (cell: Pick<NotebookCell, "proseLines">): boolean =>
|
|
18
|
-
cell.proseLines !== undefined;
|
|
19
|
-
|
|
20
|
-
/** The lines of a cell the server did not name as prose; all of them when it named none. */
|
|
21
|
-
function codeLines({ text, proseLines }: CellLines): string[] {
|
|
22
|
-
return (text ?? "")
|
|
23
|
-
.split("\n")
|
|
24
|
-
.filter(
|
|
25
|
-
(_, index) =>
|
|
26
|
-
!proseLines?.some(([start, end]) => index >= start && index <= end),
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* A query cell's caption. A served cell's is the server's alone, absent meaning none; on an
|
|
32
|
-
* unserved cell (a `.malloynb`, an older server) it is the `#"` lines in the tag block above its `run:`.
|
|
33
|
-
*/
|
|
34
|
-
export function cellCaption(
|
|
35
|
-
cell: Pick<NotebookCell, "text" | "caption" | "proseLines" | "codeLine">,
|
|
36
|
-
): string | undefined {
|
|
37
|
-
if (isServed(cell)) return cell.caption;
|
|
38
|
-
if (cell.caption !== undefined) return cell.caption;
|
|
39
|
-
const lines: string[] = [];
|
|
40
|
-
for (const raw of codeLines(cell)) {
|
|
41
|
-
const line = raw.trim();
|
|
42
|
-
if (line.startsWith("//")) continue;
|
|
43
|
-
if (!line.startsWith("#")) break;
|
|
44
|
-
if (line.startsWith('#"')) lines.push(line.slice(2).trim());
|
|
45
|
-
}
|
|
46
|
-
return lines.length > 0 ? lines.join(" ") : undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* A cell's code without its prose, which renders separately. A served cell loses exactly the
|
|
51
|
-
* lines the server named; an unserved one (a `.malloynb`, an older server) loses its `##` lines.
|
|
52
|
-
*/
|
|
53
|
-
export function stripProse(cell: CellLines): string {
|
|
54
|
-
if (isServed(cell)) return codeLines(cell).join("\n");
|
|
55
|
-
return cell.text
|
|
56
|
-
.split("\n")
|
|
57
|
-
.filter((line) => !line.trimStart().startsWith("##"))
|
|
58
|
-
.join("\n");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** One-line label for a folded definition cell: its statement kind and name. */
|
|
62
|
-
export function definitionSummary(cell: CellLines): string {
|
|
63
|
-
const line =
|
|
64
|
-
cell.codeLine !== undefined
|
|
65
|
-
? (cell.text.split("\n")[cell.codeLine] ?? "").trim()
|
|
66
|
-
: (codeLines(cell)
|
|
67
|
-
.map((raw) => raw.trim())
|
|
68
|
-
.find((l) => l && !l.startsWith("#") && !l.startsWith("//")) ??
|
|
69
|
-
"");
|
|
70
|
-
const named = /^(source|query|given|type):?\s+([A-Za-z_]\w*)/.exec(line);
|
|
71
|
-
if (named) return `${named[1]}: ${named[2]}`;
|
|
72
|
-
const keyword = /^(import|export)\b/.exec(line);
|
|
73
|
-
return keyword ? keyword[1] : line;
|
|
74
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import { Box } from "@mui/material";
|
|
5
|
-
import type { DashboardManifest } from "../../client";
|
|
6
|
-
import { DashboardProse, DashboardView } from "../Dashboard/DashboardView";
|
|
7
|
-
import type { DrillNavigation } from "../drill";
|
|
8
|
-
import { CleanNotebookContainer, CleanNotebookSection } from "../styles";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A linear report written as tiles: a one-column grid, its prose drawn bare
|
|
12
|
-
* above the tiles and its controls as a panel.
|
|
13
|
-
*/
|
|
14
|
-
export function LinearReport({
|
|
15
|
-
manifest,
|
|
16
|
-
environmentName,
|
|
17
|
-
packageName,
|
|
18
|
-
versionId,
|
|
19
|
-
documentName,
|
|
20
|
-
givens,
|
|
21
|
-
onGivensChange,
|
|
22
|
-
onDrillNavigate,
|
|
23
|
-
maxResultSize,
|
|
24
|
-
}: {
|
|
25
|
-
/** A report manifest, or the tile layout a deprecated notebook read carries. */
|
|
26
|
-
manifest: DashboardManifest;
|
|
27
|
-
environmentName: string;
|
|
28
|
-
packageName: string;
|
|
29
|
-
versionId: string | undefined;
|
|
30
|
-
documentName: string;
|
|
31
|
-
givens?: Record<string, string>;
|
|
32
|
-
onGivensChange?: (
|
|
33
|
-
givens: Record<string, string>,
|
|
34
|
-
managed: readonly string[],
|
|
35
|
-
) => void;
|
|
36
|
-
onDrillNavigate?: (target: DrillNavigation, event?: MouseEvent) => void;
|
|
37
|
-
maxResultSize?: number;
|
|
38
|
-
}) {
|
|
39
|
-
const { title, description } = manifest;
|
|
40
|
-
return (
|
|
41
|
-
<CleanNotebookContainer>
|
|
42
|
-
<CleanNotebookSection>
|
|
43
|
-
{/* chrome="none" drops the view's own header, so the prose is drawn here. */}
|
|
44
|
-
{(title || description) && (
|
|
45
|
-
<Box sx={{ mb: 2 }}>
|
|
46
|
-
<DashboardProse
|
|
47
|
-
// A linear report's text tiles have no card; its description matches them.
|
|
48
|
-
chrome="none"
|
|
49
|
-
title={title ?? ""}
|
|
50
|
-
{...(description ? { description } : {})}
|
|
51
|
-
/>
|
|
52
|
-
</Box>
|
|
53
|
-
)}
|
|
54
|
-
<DashboardView
|
|
55
|
-
manifest={manifest}
|
|
56
|
-
environmentName={environmentName}
|
|
57
|
-
packageName={packageName}
|
|
58
|
-
versionId={versionId}
|
|
59
|
-
documentName={documentName}
|
|
60
|
-
givens={givens}
|
|
61
|
-
onGivensChange={onGivensChange}
|
|
62
|
-
onNavigate={onDrillNavigate}
|
|
63
|
-
maxResultSize={maxResultSize}
|
|
64
|
-
chrome="none"
|
|
65
|
-
// A linear report's control panel, not a grid's bar.
|
|
66
|
-
controlsLayout="panel"
|
|
67
|
-
/>
|
|
68
|
-
</CleanNotebookSection>
|
|
69
|
-
</CleanNotebookContainer>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
Box,
|
|
6
|
-
Chip,
|
|
7
|
-
List,
|
|
8
|
-
ListItemButton,
|
|
9
|
-
ListItemText,
|
|
10
|
-
MenuItem,
|
|
11
|
-
TextField,
|
|
12
|
-
Typography,
|
|
13
|
-
} from "@mui/material";
|
|
14
|
-
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
15
|
-
import type { CatalogSource } from "./catalog";
|
|
16
|
-
|
|
17
|
-
/** A source select and the list of its views, which is what both "add a tile" and "add a query" pick from. */
|
|
18
|
-
export function SourceViewPicker({
|
|
19
|
-
sources,
|
|
20
|
-
source,
|
|
21
|
-
view,
|
|
22
|
-
onSource,
|
|
23
|
-
onView,
|
|
24
|
-
}: {
|
|
25
|
-
sources: CatalogSource[];
|
|
26
|
-
source: string;
|
|
27
|
-
view: string;
|
|
28
|
-
onSource: (name: string) => void;
|
|
29
|
-
onView: (name: string) => void;
|
|
30
|
-
}) {
|
|
31
|
-
const { theme } = usePublisherTheme();
|
|
32
|
-
const picked = sources.find((s) => s.name === source);
|
|
33
|
-
return (
|
|
34
|
-
<>
|
|
35
|
-
<TextField
|
|
36
|
-
select
|
|
37
|
-
size="small"
|
|
38
|
-
label="Source"
|
|
39
|
-
value={source}
|
|
40
|
-
onChange={(event) => onSource(event.target.value)}
|
|
41
|
-
inputProps={{ "aria-label": "Source" }}
|
|
42
|
-
>
|
|
43
|
-
{sources.map((s) => (
|
|
44
|
-
<MenuItem
|
|
45
|
-
key={s.name}
|
|
46
|
-
value={s.name}
|
|
47
|
-
disabled={s.views.length === 0}
|
|
48
|
-
>
|
|
49
|
-
{s.name}
|
|
50
|
-
{s.views.length === 0 && (
|
|
51
|
-
<Typography
|
|
52
|
-
component="span"
|
|
53
|
-
variant="caption"
|
|
54
|
-
sx={{ ml: 1 }}
|
|
55
|
-
>
|
|
56
|
-
declares no views
|
|
57
|
-
</Typography>
|
|
58
|
-
)}
|
|
59
|
-
{s.description && (
|
|
60
|
-
<Typography
|
|
61
|
-
component="span"
|
|
62
|
-
variant="caption"
|
|
63
|
-
sx={{ ml: 1, opacity: 0.6 }}
|
|
64
|
-
>
|
|
65
|
-
{s.description}
|
|
66
|
-
</Typography>
|
|
67
|
-
)}
|
|
68
|
-
</MenuItem>
|
|
69
|
-
))}
|
|
70
|
-
</TextField>
|
|
71
|
-
<Box>
|
|
72
|
-
<Typography variant="subtitle2" sx={{ mb: 0.5 }}>
|
|
73
|
-
View
|
|
74
|
-
</Typography>
|
|
75
|
-
<List
|
|
76
|
-
dense
|
|
77
|
-
disablePadding
|
|
78
|
-
aria-label="Views"
|
|
79
|
-
sx={{
|
|
80
|
-
maxHeight: "min(280px, 30vh)",
|
|
81
|
-
overflowY: "auto",
|
|
82
|
-
border: theme.border,
|
|
83
|
-
borderRadius: 1,
|
|
84
|
-
}}
|
|
85
|
-
>
|
|
86
|
-
{(picked?.views ?? []).map((v) => (
|
|
87
|
-
<ListItemButton
|
|
88
|
-
key={v.name}
|
|
89
|
-
selected={view === v.name}
|
|
90
|
-
onClick={() => onView(v.name)}
|
|
91
|
-
aria-label={`View ${v.name}`}
|
|
92
|
-
>
|
|
93
|
-
<ListItemText
|
|
94
|
-
primary={v.name}
|
|
95
|
-
secondary={v.description}
|
|
96
|
-
primaryTypographyProps={{
|
|
97
|
-
fontFamily: "ui-monospace, monospace",
|
|
98
|
-
fontSize: 13,
|
|
99
|
-
}}
|
|
100
|
-
/>
|
|
101
|
-
{v.chart && (
|
|
102
|
-
<Chip
|
|
103
|
-
size="small"
|
|
104
|
-
variant="outlined"
|
|
105
|
-
label={v.chart.replace(/_chart$/, "")}
|
|
106
|
-
/>
|
|
107
|
-
)}
|
|
108
|
-
</ListItemButton>
|
|
109
|
-
))}
|
|
110
|
-
{picked && picked.views.length === 0 && (
|
|
111
|
-
<Typography
|
|
112
|
-
variant="body2"
|
|
113
|
-
sx={{ p: 1.5, color: theme.tileTitle }}
|
|
114
|
-
>
|
|
115
|
-
This source declares no views.
|
|
116
|
-
</Typography>
|
|
117
|
-
)}
|
|
118
|
-
</List>
|
|
119
|
-
</Box>
|
|
120
|
-
</>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import { describe, expect, it } from "bun:test";
|
|
5
|
-
import {
|
|
6
|
-
notebookSourceRefused,
|
|
7
|
-
readNotebookSource,
|
|
8
|
-
type NotebookSource,
|
|
9
|
-
} from "./legacyNotebook";
|
|
10
|
-
|
|
11
|
-
const HEAD =
|
|
12
|
-
'## artifact { layout=linear }\nsource: a is duckdb.sql("select 1 as x")\n\n';
|
|
13
|
-
|
|
14
|
-
async function read(text: string): Promise<NotebookSource> {
|
|
15
|
-
const result = await readNotebookSource(text);
|
|
16
|
-
if (notebookSourceRefused(result)) throw new Error(result.refused);
|
|
17
|
-
return result.source;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe("readNotebookSource: chart lines", () => {
|
|
21
|
-
it("records the recognized chart line's span and where a new one goes", async () => {
|
|
22
|
-
const cell = `#" Caption\n# -bar_chart line_chart\n// c\nrun: a -> { select: x }\n`;
|
|
23
|
-
const source = await read(HEAD + cell);
|
|
24
|
-
const chart = source.cells[1].chart!;
|
|
25
|
-
expect(chart.lines.map((l) => l.text)).toEqual([
|
|
26
|
-
"# -bar_chart line_chart",
|
|
27
|
-
]);
|
|
28
|
-
const [line] = chart.lines;
|
|
29
|
-
expect(source.text.slice(line.span.start, line.span.end)).toBe(
|
|
30
|
-
"# -bar_chart line_chart\n",
|
|
31
|
-
);
|
|
32
|
-
expect(source.text.slice(chart.insertAt)).toBe(
|
|
33
|
-
"run: a -> { select: x }\n",
|
|
34
|
-
);
|
|
35
|
-
expect(chart.unmodelled).toBeUndefined();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("places a new line at the run when there are no tags, and reads CRLF", async () => {
|
|
39
|
-
const source = await read(
|
|
40
|
-
(HEAD + "run: a -> { select: x }\n").replace(/\n/g, "\r\n"),
|
|
41
|
-
);
|
|
42
|
-
const chart = source.cells[1].chart!;
|
|
43
|
-
expect(chart.lines).toEqual([]);
|
|
44
|
-
expect(source.text.slice(chart.insertAt)).toBe(
|
|
45
|
-
"run: a -> { select: x }\r\n",
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("leaves a tag with properties, or a label, as unmodelled and never as a chart line", async () => {
|
|
50
|
-
for (const line of [
|
|
51
|
-
"# bar_chart { size=spark }",
|
|
52
|
-
'# line_chart label="Revenue"',
|
|
53
|
-
"# viz=line",
|
|
54
|
-
]) {
|
|
55
|
-
const source = await read(`${HEAD}${line}\nrun: a -> { select: x }\n`);
|
|
56
|
-
const chart = source.cells[1].chart!;
|
|
57
|
-
expect(chart.lines).toEqual([]);
|
|
58
|
-
expect(chart.unmodelled).toBe(line);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("ignores chart words in captions and keeps definitions free of chart state", async () => {
|
|
63
|
-
const source = await read(
|
|
64
|
-
`${HEAD}#" The bar_chart story\nrun: a -> { select: x }\n`,
|
|
65
|
-
);
|
|
66
|
-
expect(source.cells[1].chart!.lines).toEqual([]);
|
|
67
|
-
expect(source.cells[1].chart!.unmodelled).toBeUndefined();
|
|
68
|
-
expect(source.cells[0].chart).toBeUndefined();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("does not take a word inside a quoted tag value for a chart line", async () => {
|
|
72
|
-
const source = await read(
|
|
73
|
-
`${HEAD}# label="Sales viz"\nrun: a -> { select: x }\n`,
|
|
74
|
-
);
|
|
75
|
-
expect(source.cells[1].chart!.unmodelled).toBeUndefined();
|
|
76
|
-
});
|
|
77
|
-
});
|