@malloy-publisher/sdk 0.0.382-dev → 0.2.1
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 +115 -95
- package/TREE_SHAKING.md +16 -11
- package/bunfig.toml +7 -0
- package/dist/ServerProvider-Cn_LhKda.cjs.js +1 -0
- package/dist/ServerProvider-sfabtriY.es.js +4076 -0
- package/dist/client/api.d.ts +3773 -1515
- 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 +86 -59
- package/dist/components/Connections/EditConnectionDialog.d.ts +2 -1
- package/dist/components/Connections/common.d.ts +8 -2
- package/dist/components/Dashboard/Dashboard.d.ts +62 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +57 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/DataAppViewer/DataAppViewer.d.ts +23 -0
- package/dist/components/DataAppViewer/index.d.ts +1 -0
- package/dist/components/Environment/Environment.d.ts +6 -0
- package/dist/components/Environment/index.d.ts +2 -0
- package/dist/components/Home/AddEnvironmentDialog.d.ts +1 -0
- package/dist/components/Home/DeleteEnvironmentDialog.d.ts +5 -0
- package/dist/components/Home/EditEnvironmentDialog.d.ts +7 -0
- package/dist/components/Home/Home.d.ts +2 -2
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +14 -0
- package/dist/components/Materializations/CreateMaterializationDialog.d.ts +10 -0
- package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +7 -0
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +7 -0
- package/dist/components/Materializations/ManifestView.d.ts +13 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +9 -0
- package/dist/components/Materializations/MaterializationRunsList.d.ts +15 -0
- package/dist/components/Materializations/Materializations.d.ts +7 -0
- package/dist/components/Materializations/ScheduleCard.d.ts +20 -0
- package/dist/components/Materializations/SectionLabel.d.ts +10 -0
- package/dist/components/Materializations/SetScheduleDialog.d.ts +11 -0
- package/dist/components/Materializations/TriggerChip.d.ts +10 -0
- package/dist/components/Materializations/cron.d.ts +23 -0
- package/dist/components/Materializations/index.d.ts +2 -0
- package/dist/components/Materializations/utils.d.ts +46 -0
- package/dist/components/Notebook/Notebook.d.ts +47 -4
- package/dist/components/Notebook/NotebookCell.d.ts +37 -1
- package/dist/components/Notebook/runPlan.d.ts +29 -0
- package/dist/components/Notebook/types.d.ts +10 -0
- package/dist/components/Package/ContentTypeIcon.d.ts +31 -0
- package/dist/components/Package/Package.d.ts +1 -4
- package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +5 -1
- package/dist/components/RenderedResult/renderLogs.d.ts +6 -0
- package/dist/components/ResultsDialog.d.ts +6 -1
- package/dist/components/ServerProvider.d.ts +28 -4
- package/dist/components/click_helper.d.ts +10 -1
- package/dist/components/drill/index.d.ts +3 -0
- package/dist/components/drill/markDrillableCells.d.ts +55 -0
- package/dist/components/drill/resolveDrill.d.ts +139 -0
- package/dist/components/drill/useDrill.d.ts +63 -0
- package/dist/components/given/GivenInput.d.ts +52 -0
- package/dist/components/given/GivensPanel.d.ts +47 -0
- package/dist/components/given/filterValue.d.ts +97 -0
- package/dist/components/given/index.d.ts +2 -0
- package/dist/components/given/paramCodec.d.ts +60 -0
- package/dist/components/given/utils.d.ts +17 -0
- package/dist/components/highlighter.d.ts +6 -1
- package/dist/components/index.d.ts +7 -2
- package/dist/components/styles.d.ts +47 -0
- package/dist/constants/docLinks.d.ts +12 -0
- package/dist/{core-YNpOLuB1.cjs.js → core-CqRKhtoy.cjs.js} +1 -1
- package/dist/{core-CjeTkq8O.es.js → core-DyU47reh.es.js} +1 -1
- package/dist/github-dark-BKL9xNgN.cjs.js +1 -0
- package/dist/github-dark-DenFmJkN.es.js +4 -0
- package/dist/hooks/givenValue.d.ts +10 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useDimensionFiltersFromSpec.d.ts +3 -3
- package/dist/hooks/useDimensionFiltersQuery.d.ts +3 -3
- package/dist/hooks/useDimensionalFilterRangeData.d.ts +4 -4
- package/dist/hooks/useGivensState.d.ts +64 -0
- package/dist/hooks/useModelGivens.d.ts +10 -0
- package/dist/hooks/useSuggestOptions.d.ts +78 -0
- package/dist/{index-DRDu9kIV.es.js → index-CAkFE4Ol.es.js} +41278 -28504
- package/dist/index-DD4b_bt0.cjs.js +356 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.es.js +79 -48
- package/dist/malloy-explorer.css +12 -1
- package/dist/sdk.css +1 -1
- package/dist/theme/ThemeContext.d.ts +45 -0
- package/dist/theme/buildMalloyExplicitTheme.d.ts +34 -0
- package/dist/theme/buildTableCssVars.d.ts +41 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +16 -0
- package/dist/theme/defaults.d.ts +7 -0
- package/dist/theme/index.d.ts +8 -0
- package/dist/theme/keys.d.ts +20 -0
- package/dist/theme/readChartAnnotations.d.ts +23 -0
- package/dist/theme/resolveTheme.d.ts +22 -0
- package/dist/theme/types.d.ts +70 -0
- package/dist/utils/dataAppEmbed.d.ts +44 -0
- package/dist/utils/formatting.d.ts +1 -1
- package/dist/utils/malloyString.d.ts +7 -0
- package/dist/utils/parsing.d.ts +2 -2
- package/dist/utils/queryClient.d.ts +5 -0
- package/package.json +19 -8
- package/src/client-entry.ts +3 -0
- package/src/components/AnalyzePackageButton.tsx +9 -3
- package/src/components/ApiErrorDisplay.tsx +3 -0
- package/src/components/Connections/AddConnectionDialog.tsx +132 -25
- package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
- package/src/components/Connections/EditConnectionDialog.tsx +167 -37
- package/src/components/Connections/common.ts +94 -3
- package/src/components/DOMElement/DOMElement.tsx +3 -0
- package/src/components/DOMElement/index.ts +3 -0
- package/src/components/Dashboard/Dashboard.spec.tsx +216 -0
- package/src/components/Dashboard/Dashboard.tsx +458 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +81 -0
- package/src/components/Dashboard/DashboardTile.tsx +199 -0
- package/src/components/Dashboard/index.ts +5 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +35 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
- package/src/components/DataAppViewer/index.ts +4 -0
- package/src/components/{Project → Environment}/About.tsx +11 -4
- package/src/components/Environment/AddPackageDialog.tsx +202 -0
- package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
- package/src/components/Environment/Connections.tsx +391 -0
- package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
- package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
- package/src/components/Environment/Environment.tsx +89 -0
- package/src/components/Environment/Packages.tsx +206 -0
- package/src/components/Environment/index.ts +5 -0
- package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
- package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
- package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
- package/src/components/Home/Home.tsx +386 -408
- package/src/components/Home/index.ts +3 -0
- package/src/components/Loading.tsx +3 -0
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
- package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
- package/src/components/Materializations/ManifestView.tsx +87 -0
- package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
- package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
- package/src/components/Materializations/Materializations.tsx +355 -0
- package/src/components/Materializations/ScheduleCard.tsx +231 -0
- package/src/components/Materializations/SectionLabel.tsx +30 -0
- package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
- package/src/components/Materializations/TriggerChip.tsx +44 -0
- package/src/components/Materializations/cron.ts +124 -0
- package/src/components/Materializations/index.ts +5 -0
- package/src/components/Materializations/utils.ts +145 -0
- package/src/components/Model/Model.tsx +44 -2
- package/src/components/Model/ModelCell.tsx +14 -5
- package/src/components/Model/ModelExplorer.tsx +3 -0
- package/src/components/Model/ModelExplorerDialog.tsx +4 -1
- package/src/components/Model/SourcesExplorer.tsx +9 -6
- package/src/components/Model/index.ts +3 -0
- package/src/components/Model/useModelData.ts +6 -3
- package/src/components/Notebook/Notebook.spec.tsx +88 -0
- package/src/components/Notebook/Notebook.tsx +476 -339
- package/src/components/Notebook/NotebookCell.tsx +264 -25
- package/src/components/Notebook/index.ts +3 -0
- package/src/components/Notebook/runPlan.spec.ts +155 -0
- package/src/components/Notebook/runPlan.ts +67 -0
- package/src/components/Notebook/types.ts +14 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
- package/src/components/Package/ContentTypeIcon.tsx +177 -0
- package/src/components/Package/FileTreeView.tsx +3 -0
- package/src/components/Package/Models.tsx +7 -4
- package/src/components/Package/Package.spec.tsx +113 -0
- package/src/components/Package/Package.tsx +692 -59
- package/src/components/Package/index.ts +3 -0
- package/src/components/QueryResult/QueryResult.tsx +17 -8
- package/src/components/QueryResult/index.ts +3 -0
- package/src/components/RenderedResult/RenderedResult.tsx +725 -67
- package/src/components/RenderedResult/ResultContainer.tsx +71 -2
- package/src/components/RenderedResult/index.ts +3 -0
- package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
- package/src/components/RenderedResult/renderLogs.ts +43 -0
- package/src/components/ResultsDialog.tsx +13 -1
- package/src/components/ServerProvider.tsx +175 -51
- package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
- package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
- package/src/components/Workbook/ModelPicker.tsx +7 -4
- package/src/components/Workbook/MutableCell.tsx +10 -5
- package/src/components/Workbook/Workbook.tsx +8 -5
- package/src/components/Workbook/WorkbookList.tsx +3 -0
- package/src/components/Workbook/WorkbookManager.ts +3 -0
- package/src/components/Workbook/WorkbookStorage.ts +3 -0
- package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
- package/src/components/Workbook/index.ts +3 -0
- package/src/components/click_helper.ts +17 -1
- package/src/components/drill/index.ts +28 -0
- package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
- package/src/components/drill/markDrillableCells.spec.ts +109 -0
- package/src/components/drill/markDrillableCells.ts +314 -0
- package/src/components/drill/resolveDrill.spec.ts +449 -0
- package/src/components/drill/resolveDrill.ts +375 -0
- package/src/components/drill/useDrill.tsx +203 -0
- package/src/components/filter/DimensionFilter.tsx +3 -0
- package/src/components/filter/index.ts +3 -0
- package/src/components/filter/utils.ts +16 -5
- package/src/components/given/GivenInput.spec.tsx +689 -0
- package/src/components/given/GivenInput.tsx +801 -0
- package/src/components/given/GivensPanel.spec.tsx +175 -0
- package/src/components/given/GivensPanel.tsx +195 -0
- package/src/components/given/filterValue.spec.ts +364 -0
- package/src/components/given/filterValue.ts +207 -0
- package/src/components/given/index.ts +9 -0
- package/src/components/given/paramCodec.spec.ts +857 -0
- package/src/components/given/paramCodec.ts +483 -0
- package/src/components/given/utils.spec.ts +60 -0
- package/src/components/given/utils.ts +79 -0
- package/src/components/highlighter.ts +22 -5
- package/src/components/index.ts +10 -2
- package/src/components/styles.ts +82 -33
- package/src/constants/docLinks.spec.ts +54 -0
- package/src/constants/docLinks.ts +46 -0
- package/src/hooks/givenValue.ts +13 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useDimensionFilters.ts +4 -7
- package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
- package/src/hooks/useDimensionFiltersQuery.ts +10 -13
- package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
- package/src/hooks/useGivensState.spec.ts +449 -0
- package/src/hooks/useGivensState.ts +340 -0
- package/src/hooks/useModelGivens.ts +29 -0
- package/src/hooks/useQueryWithApiError.ts +3 -0
- package/src/hooks/useRawQueryData.ts +6 -3
- package/src/hooks/useSuggestOptions.dom.spec.ts +91 -0
- package/src/hooks/useSuggestOptions.spec.ts +112 -0
- package/src/hooks/useSuggestOptions.ts +268 -0
- package/src/index.ts +10 -1
- package/src/react-app-env.d.ts +3 -0
- package/src/theme/ThemeContext.tsx +86 -0
- package/src/theme/buildMalloyExplicitTheme.ts +61 -0
- package/src/theme/buildTableCssVars.spec.ts +86 -0
- package/src/theme/buildTableCssVars.ts +98 -0
- package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
- package/src/theme/buildVegaThemeOverride.ts +47 -0
- package/src/theme/defaults.ts +78 -0
- package/src/theme/index.ts +11 -0
- package/src/theme/keys.ts +32 -0
- package/src/theme/readChartAnnotations.spec.ts +58 -0
- package/src/theme/readChartAnnotations.ts +69 -0
- package/src/theme/resolveTheme.spec.ts +160 -0
- package/src/theme/resolveTheme.ts +121 -0
- package/src/theme/types.ts +79 -0
- package/src/utils/dataAppEmbed.spec.ts +63 -0
- package/src/utils/dataAppEmbed.ts +84 -0
- package/src/utils/formatting.spec.ts +25 -21
- package/src/utils/formatting.ts +11 -7
- package/src/utils/malloyString.spec.ts +24 -0
- package/src/utils/malloyString.ts +12 -0
- package/src/utils/parsing.spec.ts +26 -19
- package/src/utils/parsing.ts +11 -6
- package/src/utils/queryClient.ts +17 -0
- package/test/README.md +185 -0
- package/test/serverProvider.tsx +72 -0
- package/test/setup.ts +29 -0
- package/tsconfig.json +12 -1
- package/tsconfig.spec.json +22 -0
- package/vite.config.ts +3 -0
- package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
- package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
- package/dist/components/Home/AddProjectDialog.d.ts +0 -1
- package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
- package/dist/components/Home/EditProjectDialog.d.ts +0 -7
- package/dist/components/Package/Config.d.ts +0 -5
- package/dist/components/Package/Databases.d.ts +0 -5
- package/dist/components/Package/Notebooks.d.ts +0 -6
- package/dist/components/Project/Project.d.ts +0 -6
- package/dist/components/Project/index.d.ts +0 -2
- package/dist/index-BOLBP6_i.cjs.js +0 -233
- package/src/components/Package/Config.tsx +0 -97
- package/src/components/Package/Connections.tsx +0 -373
- package/src/components/Package/Databases.tsx +0 -228
- package/src/components/Package/Notebooks.tsx +0 -77
- package/src/components/Project/AddPackageDialog.tsx +0 -159
- package/src/components/Project/Packages.tsx +0 -191
- package/src/components/Project/Project.tsx +0 -52
- package/src/components/Project/index.ts +0 -2
- /package/dist/components/{Project → Environment}/About.d.ts +0 -0
- /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
- /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
- /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What the notebook's run effect should do about the state it just observed.
|
|
6
|
+
*
|
|
7
|
+
* Pulled out as a pure function because the inline version produced two defects
|
|
8
|
+
* that no test could reach: it first lost the bound on concurrent runs
|
|
9
|
+
* entirely, then, once a settle delay put the bound back, it let an abandoned
|
|
10
|
+
* run fire. Both were reasoning errors about
|
|
11
|
+
* three interacting pieces of state, which is exactly what a table of cases
|
|
12
|
+
* pins and a component test does not.
|
|
13
|
+
*/
|
|
14
|
+
export interface RunPlanInput {
|
|
15
|
+
/** Whether the notebook is loaded and runnable at all. */
|
|
16
|
+
ready: boolean;
|
|
17
|
+
/** Key of the run that has already been dispatched, or null before the first. */
|
|
18
|
+
lastRunKey: string | null;
|
|
19
|
+
/** Key of a run currently waiting out the settle delay, if any. */
|
|
20
|
+
pendingKey: string | undefined;
|
|
21
|
+
/** Key for the state the notebook is in now. */
|
|
22
|
+
runKey: string;
|
|
23
|
+
/** The `resourceUri|generation` prefix of {@link runKey}, without the parameters. */
|
|
24
|
+
documentKey: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface RunPlan {
|
|
28
|
+
/** Clear the pending timer, because what it would run is no longer current. */
|
|
29
|
+
cancelPending: boolean;
|
|
30
|
+
/** `now` skips the settle delay; `settle` waits it out; `none` does nothing. */
|
|
31
|
+
dispatch: "now" | "settle" | "none";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function planRun({
|
|
35
|
+
ready,
|
|
36
|
+
lastRunKey,
|
|
37
|
+
pendingKey,
|
|
38
|
+
runKey,
|
|
39
|
+
documentKey,
|
|
40
|
+
}: RunPlanInput): RunPlan {
|
|
41
|
+
// A notebook that is not loaded still has to disarm. This is the reason the
|
|
42
|
+
// readiness check belongs here rather than as an early return in the effect:
|
|
43
|
+
// as an early return it skipped the cancellation below, so navigating away
|
|
44
|
+
// inside the settle window left a timer holding the PREVIOUS notebook's
|
|
45
|
+
// closure, which then ran a full wave of cells against the notebook the
|
|
46
|
+
// reader had just left and wrote them into the one now on screen.
|
|
47
|
+
if (!ready) {
|
|
48
|
+
return { cancelPending: pendingKey !== undefined, dispatch: "none" };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// A pending run for any other key is stale the moment the notebook moves on,
|
|
52
|
+
// INCLUDING when it moves back to a key that has already run. That last case
|
|
53
|
+
// is the one that bit: typing a value and deleting it again inside the
|
|
54
|
+
// window returns to an already-run key, and leaving the timer armed meant the
|
|
55
|
+
// abandoned value's results landed on screen with nothing to correct them.
|
|
56
|
+
const cancelPending = pendingKey !== undefined && pendingKey !== runKey;
|
|
57
|
+
|
|
58
|
+
if (lastRunKey === runKey) return { cancelPending, dispatch: "none" };
|
|
59
|
+
if (pendingKey === runKey) return { cancelPending, dispatch: "none" };
|
|
60
|
+
|
|
61
|
+
// Only a changed PARAMETER waits. A first run, a different notebook, and a
|
|
62
|
+
// package reload all change the document rather than a value, and none of
|
|
63
|
+
// them is a burst worth coalescing: delaying them is just a blank screen.
|
|
64
|
+
const changedDocument =
|
|
65
|
+
lastRunKey === null || !lastRunKey.startsWith(`${documentKey}|`);
|
|
66
|
+
return { cancelPending, dispatch: changedDocument ? "now" : "settle" };
|
|
67
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { NotebookCell as ClientNotebookCell } from "../../client";
|
|
2
5
|
|
|
3
6
|
/**
|
|
@@ -21,4 +24,15 @@ export interface EnhancedNotebookCell extends ClientNotebookCell {
|
|
|
21
24
|
* that become available in this cell (e.g., from imports or source definitions)
|
|
22
25
|
*/
|
|
23
26
|
newSources?: string[];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Why this cell has no result, when the server refused to run it.
|
|
30
|
+
*
|
|
31
|
+
* A cell that throws used to be logged to the console and nothing else, so
|
|
32
|
+
* the reader got an empty space with no indication anything had happened.
|
|
33
|
+
* That was survivable while the only way to reach it was a server fault; it
|
|
34
|
+
* stopped being survivable once a model with a required `#(filter)` began
|
|
35
|
+
* failing every cell by design.
|
|
36
|
+
*/
|
|
37
|
+
error?: string;
|
|
24
38
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { MALLOY_ACCENT } from "../styles";
|
|
6
|
+
import { CONTENT_TINT, type ContentType } from "./ContentTypeIcon";
|
|
7
|
+
|
|
8
|
+
/** Relative luminance, WCAG 2.x definition. */
|
|
9
|
+
function luminance(hex: string): number {
|
|
10
|
+
const channels = [1, 3, 5].map(
|
|
11
|
+
(i) => parseInt(hex.slice(i, i + 2), 16) / 255,
|
|
12
|
+
);
|
|
13
|
+
const [r, g, b] = channels.map((c) =>
|
|
14
|
+
c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4,
|
|
15
|
+
);
|
|
16
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function contrastWithWhite(hex: string): number {
|
|
20
|
+
return (1 + 0.05) / (luminance(hex) + 0.05);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe("CONTENT_TINT", () => {
|
|
24
|
+
/**
|
|
25
|
+
* The whole point of the map. Before the package row derived its color from
|
|
26
|
+
* its type, four of the six rows were handed the same teal by four separate
|
|
27
|
+
* call sites, so color distinguished two kinds out of six. A repeat here is
|
|
28
|
+
* that regression arriving again, and nothing renders differently enough for
|
|
29
|
+
* a person to notice it in review.
|
|
30
|
+
*/
|
|
31
|
+
it("gives every content type its own color", () => {
|
|
32
|
+
const values = Object.values(CONTENT_TINT);
|
|
33
|
+
expect(new Set(values).size).toBe(values.length);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Content types whose colour predates this bar. `report` is backed by
|
|
39
|
+
* `MALLOY_BRAND.teal` at 2.5:1, which is below it; that is inherited from the
|
|
40
|
+
* logo and is a brand decision rather than a component one.
|
|
41
|
+
*
|
|
42
|
+
* Keyed by content TYPE rather than by colour, which is the whole point. A new
|
|
43
|
+
* type handed teal is not grandfathered and fails, and fixing teal one day
|
|
44
|
+
* leaves this entry merely unused rather than turning a correct fix into a red
|
|
45
|
+
* suite.
|
|
46
|
+
*/
|
|
47
|
+
const GRANDFATHERED: ContentType[] = ["report"];
|
|
48
|
+
|
|
49
|
+
describe("CONTENT_TINT contrast", () => {
|
|
50
|
+
/**
|
|
51
|
+
* Every tint fills a 32px backplate behind an 18px white glyph, so it has to
|
|
52
|
+
* clear 3:1
|
|
53
|
+
* against white, WCAG's minimum for a graphical object. Asserted rather than
|
|
54
|
+
* written down, because the failure is invisible: a lighter colour looks fine
|
|
55
|
+
* in a screenshot and the icon simply stops being readable.
|
|
56
|
+
*
|
|
57
|
+
* Over `CONTENT_TINT` rather than over `MALLOY_ACCENT`, because the tints are
|
|
58
|
+
* what actually get painted. Asserting the accent palette alone left three of
|
|
59
|
+
* the six painted values unchecked.
|
|
60
|
+
*/
|
|
61
|
+
it.each(
|
|
62
|
+
Object.entries(CONTENT_TINT).filter(
|
|
63
|
+
([type]) => !GRANDFATHERED.includes(type as ContentType),
|
|
64
|
+
),
|
|
65
|
+
)("%s clears 3:1 against white", (_type, hex) => {
|
|
66
|
+
expect(contrastWithWhite(hex)).toBeGreaterThanOrEqual(3);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Guards the exception list against drift: a grandfathered name that no
|
|
70
|
+
// longer matches a `ContentType` fails here rather than silently exempting
|
|
71
|
+
// nothing. It does NOT catch the list being emptied, which passes
|
|
72
|
+
// vacuously; that case is caught instead by the contrast assertion for the
|
|
73
|
+
// type that stops being skipped, and an empty list is the desired end state
|
|
74
|
+
// anyway.
|
|
75
|
+
it("grandfathers only types that exist", () => {
|
|
76
|
+
for (const type of GRANDFATHERED) {
|
|
77
|
+
expect(CONTENT_TINT).toHaveProperty(type);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("MALLOY_ACCENT", () => {
|
|
83
|
+
// The accents were chosen against this bar, so they hold it even before any
|
|
84
|
+
// of them is assigned to a content type.
|
|
85
|
+
it.each(Object.entries(MALLOY_ACCENT))(
|
|
86
|
+
"%s clears 3:1 against white",
|
|
87
|
+
(_name, hex) => {
|
|
88
|
+
expect(contrastWithWhite(hex)).toBeGreaterThanOrEqual(3);
|
|
89
|
+
},
|
|
90
|
+
);
|
|
91
|
+
});
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import SvgIcon, { SvgIconProps } from "@mui/material/SvgIcon";
|
|
5
|
+
import { MALLOY_ACCENT, MALLOY_BRAND } from "../styles";
|
|
6
|
+
|
|
7
|
+
export type ContentType =
|
|
8
|
+
| "report"
|
|
9
|
+
| "model"
|
|
10
|
+
| "data"
|
|
11
|
+
| "materialization"
|
|
12
|
+
| "dataApp"
|
|
13
|
+
| "dashboard";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The backplate color behind each icon. One per content type and no repeats: on
|
|
17
|
+
* a page that lists all six, a shared color reads as a shared kind, and the
|
|
18
|
+
* glyphs are small enough that color does most of the telling apart.
|
|
19
|
+
*
|
|
20
|
+
* The logo's three go to the three artifacts a reader opens to look at data,
|
|
21
|
+
* dashboards and notebooks and the models under them, and the accents to the
|
|
22
|
+
* rest, so the brand leads on the things the page is mostly for. Not a
|
|
23
|
+
* seniority ranking: dashboards are the newest thing a package can hold, and
|
|
24
|
+
* Package Data is among the oldest and takes an accent.
|
|
25
|
+
*
|
|
26
|
+
* Exhaustive by type rather than by a default, so adding a `ContentType` is a
|
|
27
|
+
* compile error here instead of a row that silently paints itself the same as
|
|
28
|
+
* its neighbour.
|
|
29
|
+
*/
|
|
30
|
+
export const CONTENT_TINT: Record<ContentType, string> = {
|
|
31
|
+
dashboard: MALLOY_BRAND.orange,
|
|
32
|
+
report: MALLOY_BRAND.teal,
|
|
33
|
+
model: MALLOY_BRAND.darkBlue,
|
|
34
|
+
dataApp: MALLOY_ACCENT.violet,
|
|
35
|
+
data: MALLOY_ACCENT.moss,
|
|
36
|
+
materialization: MALLOY_ACCENT.magenta,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
interface ContentTypeIconProps extends Omit<SvgIconProps, "fontSize"> {
|
|
40
|
+
type: ContentType;
|
|
41
|
+
/** Pixel size of the rendered icon. */
|
|
42
|
+
size?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Inline SVGs that visually match Central Icons'
|
|
47
|
+
* round-outlined-radius-2-stroke-1 family
|
|
48
|
+
* (IconFileChart, Icon3dBoxTop, IconTable). Reimplemented as plain SVG
|
|
49
|
+
* so the SDK does not pick up the paid @central-icons-react dependency.
|
|
50
|
+
*/
|
|
51
|
+
export default function ContentTypeIcon({
|
|
52
|
+
type,
|
|
53
|
+
size = 18,
|
|
54
|
+
sx,
|
|
55
|
+
...rest
|
|
56
|
+
}: ContentTypeIconProps) {
|
|
57
|
+
return (
|
|
58
|
+
<SvgIcon
|
|
59
|
+
{...rest}
|
|
60
|
+
viewBox="0 0 24 24"
|
|
61
|
+
sx={{
|
|
62
|
+
width: size,
|
|
63
|
+
height: size,
|
|
64
|
+
fill: "none",
|
|
65
|
+
stroke: "currentColor",
|
|
66
|
+
strokeWidth: 1.5,
|
|
67
|
+
strokeLinecap: "round",
|
|
68
|
+
strokeLinejoin: "round",
|
|
69
|
+
...sx,
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
{CONTENT_GLYPH[type]()}
|
|
73
|
+
</SvgIcon>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The glyph for each content type, a `Record` for the same reason
|
|
79
|
+
* `CONTENT_TINT` is one. This was a chain of `type === "x" && <Path />`, which
|
|
80
|
+
* type-checks with no arm for a new content type and renders an empty `<svg>`
|
|
81
|
+
* on a coloured backplate: the colour half of the signal failed loudly at
|
|
82
|
+
* compile time and the glyph half failed silently at runtime. Two halves of one
|
|
83
|
+
* signal should fail the same way. The failure mode differs at runtime as well
|
|
84
|
+
* as at compile time: an unknown type throws here, where the old chain rendered
|
|
85
|
+
* an empty `<svg>`. Unreachable today, since every call site passes a literal,
|
|
86
|
+
* and a crash is the better of the two if it ever is reachable.
|
|
87
|
+
*/
|
|
88
|
+
const CONTENT_GLYPH: Record<ContentType, () => React.ReactElement> = {
|
|
89
|
+
report: FileChartPath,
|
|
90
|
+
model: BoxTopPath,
|
|
91
|
+
data: TablePath,
|
|
92
|
+
materialization: StackPath,
|
|
93
|
+
dataApp: BrowserWindowPath,
|
|
94
|
+
dashboard: DashboardGridPath,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** File outline with a folded top-right corner and three chart bars inside. */
|
|
98
|
+
function FileChartPath() {
|
|
99
|
+
return (
|
|
100
|
+
<>
|
|
101
|
+
<path d="M14 3 H6 a2 2 0 0 0 -2 2 v14 a2 2 0 0 0 2 2 h12 a2 2 0 0 0 2 -2 V9 z" />
|
|
102
|
+
<path d="M14 3 v4 a2 2 0 0 0 2 2 h4" />
|
|
103
|
+
<path d="M8 17 v-3" />
|
|
104
|
+
<path d="M12 17 v-6" />
|
|
105
|
+
<path d="M16 17 v-4" />
|
|
106
|
+
</>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Cube viewed from above with visible top face — matches Icon3dBoxTop. */
|
|
111
|
+
function BoxTopPath() {
|
|
112
|
+
return (
|
|
113
|
+
<>
|
|
114
|
+
<path d="M12 3 L4 7 v10 l8 4 l8 -4 V7 z" />
|
|
115
|
+
<path d="M4 7 l8 4 l8 -4" />
|
|
116
|
+
<path d="M12 11 v10" />
|
|
117
|
+
</>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Rounded grid icon — matches IconTable. */
|
|
122
|
+
function TablePath() {
|
|
123
|
+
return (
|
|
124
|
+
<>
|
|
125
|
+
<rect x="3.5" y="3.5" width="17" height="17" rx="2" />
|
|
126
|
+
<path d="M3.5 9.5 H20.5" />
|
|
127
|
+
<path d="M9.5 3.5 V20.5" />
|
|
128
|
+
</>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Stacked layers icon for materialized output tables. */
|
|
133
|
+
function StackPath() {
|
|
134
|
+
return (
|
|
135
|
+
<>
|
|
136
|
+
<path d="M12 3 L21 7.5 L12 12 L3 7.5 Z" />
|
|
137
|
+
<path d="M3 12 L12 16.5 L21 12" />
|
|
138
|
+
<path d="M3 16.5 L12 21 L21 16.5" />
|
|
139
|
+
</>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Panels of unequal size in one frame: the grid of tiles a dashboard lays out.
|
|
145
|
+
*
|
|
146
|
+
* The neighbour to stay distinct from is the TABLE glyph, not the data app's
|
|
147
|
+
* browser window. Both this and the table are a rounded rect with the same
|
|
148
|
+
* `M3.5 9.5` divider, so before the second divider the whole difference between
|
|
149
|
+
* them was one vertical stroke: `M12 9.5 V20.5` here against the table's
|
|
150
|
+
* `M9.5 3.5 V20.5`: shifted 2.5 across, and starting at the divider rather
|
|
151
|
+
* than at the top of the frame. That read as the
|
|
152
|
+
* same icon at 18px, with the Dashboards and Databases sections on one page.
|
|
153
|
+
* The second divider is what makes this one read as a grid rather than as
|
|
154
|
+
* columns.
|
|
155
|
+
*/
|
|
156
|
+
function DashboardGridPath() {
|
|
157
|
+
return (
|
|
158
|
+
<>
|
|
159
|
+
<rect x="3.5" y="3.5" width="17" height="17" rx="2" />
|
|
160
|
+
<path d="M3.5 9.5 H20.5" />
|
|
161
|
+
<path d="M12 9.5 V20.5" />
|
|
162
|
+
<path d="M12 15 H20.5" />
|
|
163
|
+
</>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Browser-window outline with an address-bar separator and content lines. */
|
|
168
|
+
function BrowserWindowPath() {
|
|
169
|
+
return (
|
|
170
|
+
<>
|
|
171
|
+
<rect x="3.5" y="4.5" width="17" height="15" rx="2" />
|
|
172
|
+
<path d="M3.5 9.5 H20.5" />
|
|
173
|
+
<path d="M7 13.5 H17" />
|
|
174
|
+
<path d="M7 16.5 H13" />
|
|
175
|
+
</>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { Box, Typography } from "@mui/material";
|
|
2
5
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
3
6
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
@@ -20,16 +23,16 @@ interface ModelsProps {
|
|
|
20
23
|
|
|
21
24
|
export default function Models({ onClickModelFile, resourceUri }: ModelsProps) {
|
|
22
25
|
const {
|
|
23
|
-
|
|
26
|
+
environmentName: environmentName,
|
|
24
27
|
packageName: packageName,
|
|
25
28
|
versionId: versionId,
|
|
26
29
|
} = parseResourceUri(resourceUri);
|
|
27
30
|
const { apiClients } = useServer();
|
|
28
31
|
|
|
29
32
|
const { data, isError, error, isSuccess } = useQueryWithApiError({
|
|
30
|
-
queryKey: ["models",
|
|
33
|
+
queryKey: ["models", environmentName, packageName, versionId],
|
|
31
34
|
queryFn: () =>
|
|
32
|
-
apiClients.models.listModels(
|
|
35
|
+
apiClients.models.listModels(environmentName, packageName, versionId),
|
|
33
36
|
});
|
|
34
37
|
|
|
35
38
|
return (
|
|
@@ -46,7 +49,7 @@ export default function Models({ onClickModelFile, resourceUri }: ModelsProps) {
|
|
|
46
49
|
{isError && (
|
|
47
50
|
<ApiErrorDisplay
|
|
48
51
|
error={error}
|
|
49
|
-
context={`${
|
|
52
|
+
context={`${environmentName} > ${packageName} > Models`}
|
|
50
53
|
/>
|
|
51
54
|
)}
|
|
52
55
|
{isSuccess && data.data.length > 0 && (
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The dashboards listing follows the package's other listings; the data apps
|
|
6
|
+
* do not.
|
|
7
|
+
*
|
|
8
|
+
* Two exceptions that look alike and are not: `/data-apps` serves static files
|
|
9
|
+
* and declares no `versionId` in the spec, while `list-dashboards` declares one
|
|
10
|
+
* exactly as `list-notebooks` does. Pinned as a pair, because the cost of
|
|
11
|
+
* confusing them is a listing that answers for the wrong version.
|
|
12
|
+
*/
|
|
13
|
+
import { beforeEach, expect, it, mock } from "bun:test";
|
|
14
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
15
|
+
import {
|
|
16
|
+
cacheKeys,
|
|
17
|
+
clearCache,
|
|
18
|
+
mockServerProvider,
|
|
19
|
+
pending,
|
|
20
|
+
serverWrapper,
|
|
21
|
+
} from "../../../test/serverProvider";
|
|
22
|
+
|
|
23
|
+
const listDashboards = mock(
|
|
24
|
+
(_environmentName: string, _packageName: string, _versionId?: string) =>
|
|
25
|
+
pending(),
|
|
26
|
+
);
|
|
27
|
+
const listDataApps = mock((_environmentName: string, _packageName: string) =>
|
|
28
|
+
pending(),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
mockServerProvider({
|
|
32
|
+
packages: { getPackage: pending },
|
|
33
|
+
// Resolved, not pending: the page withholds every section until the
|
|
34
|
+
// notebooks and dashboards listings have both settled.
|
|
35
|
+
notebooks: { listNotebooks: () => Promise.resolve({ data: [] }) },
|
|
36
|
+
models: { listModels: pending },
|
|
37
|
+
databases: { listDatabases: pending },
|
|
38
|
+
dataApps: { listDataApps },
|
|
39
|
+
dashboards: { listDashboards },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const { default: Package } = await import("./Package");
|
|
43
|
+
|
|
44
|
+
const packageAt = (versionId?: string) => (
|
|
45
|
+
<Package
|
|
46
|
+
resourceUri={
|
|
47
|
+
versionId === undefined
|
|
48
|
+
? "publisher://environments/env/packages/pkg"
|
|
49
|
+
: `publisher://environments/env/packages/pkg?versionId=${versionId}`
|
|
50
|
+
}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
clearCache();
|
|
56
|
+
listDashboards.mockClear();
|
|
57
|
+
listDataApps.mockClear();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("lists a version's dashboards, and keys the listing on it", async () => {
|
|
61
|
+
render(packageAt("v2"), { wrapper: serverWrapper });
|
|
62
|
+
|
|
63
|
+
await waitFor(() => expect(listDashboards).toHaveBeenCalled());
|
|
64
|
+
expect(listDashboards.mock.calls[0]).toEqual(["env", "pkg", "v2"]);
|
|
65
|
+
expect(cacheKeys("dashboards")[0]).toContain('"v2"');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("keys an unversioned listing beside the package's other listings", async () => {
|
|
69
|
+
render(packageAt(), { wrapper: serverWrapper });
|
|
70
|
+
|
|
71
|
+
await waitFor(() => expect(listDashboards).toHaveBeenCalled());
|
|
72
|
+
expect(listDashboards.mock.calls[0]).toEqual(["env", "pkg", undefined]);
|
|
73
|
+
expect(cacheKeys("dashboards")[0]).toBe(
|
|
74
|
+
'["dashboards","env","pkg",null,"http://localhost/api/v0"]',
|
|
75
|
+
);
|
|
76
|
+
expect(cacheKeys("notebooks")[0]).toBe(
|
|
77
|
+
'["notebooks","env","pkg",null,"http://localhost/api/v0"]',
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("still leaves the data apps unversioned", async () => {
|
|
82
|
+
render(packageAt("v2"), { wrapper: serverWrapper });
|
|
83
|
+
|
|
84
|
+
await waitFor(() => expect(listDataApps).toHaveBeenCalled());
|
|
85
|
+
expect(listDataApps.mock.calls[0]).toEqual(["env", "pkg"]);
|
|
86
|
+
expect(cacheKeys("data-apps")[0]).not.toContain('"v2"');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("says so when the dashboards listing fails, rather than showing none", async () => {
|
|
90
|
+
// Sending a version gives a host that refuses the parameter a way to fail
|
|
91
|
+
// this listing alone. Falling back to an empty list would report that as
|
|
92
|
+
// "no dashboards", which is a wrong answer wearing a right one's clothes.
|
|
93
|
+
listDashboards.mockImplementationOnce(() =>
|
|
94
|
+
Promise.reject({ response: { status: 501 } }),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
render(packageAt("v2"), { wrapper: serverWrapper });
|
|
98
|
+
|
|
99
|
+
expect(await screen.findByText(/Could not list/)).toBeDefined();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("keeps showing no section at all for an older server with no route", async () => {
|
|
103
|
+
// A 404 is a Publisher that predates the endpoint, which genuinely has no
|
|
104
|
+
// dashboards to list. Unchanged: no error, no section.
|
|
105
|
+
listDashboards.mockImplementationOnce(() =>
|
|
106
|
+
Promise.reject({ response: { status: 404 } }),
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
render(packageAt(), { wrapper: serverWrapper });
|
|
110
|
+
|
|
111
|
+
await waitFor(() => expect(listDashboards).toHaveBeenCalled());
|
|
112
|
+
expect(screen.queryAllByText(/Could not list/)).toHaveLength(0);
|
|
113
|
+
});
|