@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
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
5
|
import type { HighlighterCore } from "shiki/core";
|
|
3
6
|
|
|
@@ -617,12 +620,15 @@ const malloySQLTMGrammar = {
|
|
|
617
620
|
},
|
|
618
621
|
};
|
|
619
622
|
|
|
620
|
-
const
|
|
623
|
+
const LIGHT_THEME = "github-light";
|
|
624
|
+
const DARK_THEME = "github-dark";
|
|
621
625
|
|
|
622
626
|
// Lazy, cached highlighter factory. The heavy Shiki WASM engine, grammars, and
|
|
623
627
|
// themes are only pulled into the module graph the first time `highlight()` is
|
|
624
628
|
// actually called, so consumers that import the SDK but never render Malloy
|
|
625
|
-
// code don't pay for the ~600KB Oniguruma WASM chunk.
|
|
629
|
+
// code don't pay for the ~600KB Oniguruma WASM chunk. Both light and dark
|
|
630
|
+
// themes are loaded together so the mode toggle doesn't trigger a second
|
|
631
|
+
// network round-trip on first switch.
|
|
626
632
|
let highlighterPromise: Promise<HighlighterCore> | undefined;
|
|
627
633
|
|
|
628
634
|
function getHighlighter(): Promise<HighlighterCore> {
|
|
@@ -635,6 +641,7 @@ function getHighlighter(): Promise<HighlighterCore> {
|
|
|
635
641
|
{ default: langJson },
|
|
636
642
|
{ default: langTypescript },
|
|
637
643
|
{ default: themeGithubLight },
|
|
644
|
+
{ default: themeGithubDark },
|
|
638
645
|
] = await Promise.all([
|
|
639
646
|
import("shiki/core"),
|
|
640
647
|
import("shiki/engine/oniguruma"),
|
|
@@ -642,11 +649,12 @@ function getHighlighter(): Promise<HighlighterCore> {
|
|
|
642
649
|
import("@shikijs/langs/json"),
|
|
643
650
|
import("@shikijs/langs/typescript"),
|
|
644
651
|
import("@shikijs/themes/github-light"),
|
|
652
|
+
import("@shikijs/themes/github-dark"),
|
|
645
653
|
]);
|
|
646
654
|
|
|
647
655
|
return createHighlighterCore({
|
|
648
656
|
engine: createOnigurumaEngine(import("shiki/wasm")),
|
|
649
|
-
themes: [themeGithubLight],
|
|
657
|
+
themes: [themeGithubLight, themeGithubDark],
|
|
650
658
|
langs: [
|
|
651
659
|
langSql,
|
|
652
660
|
langJson,
|
|
@@ -670,10 +678,19 @@ function getHighlighter(): Promise<HighlighterCore> {
|
|
|
670
678
|
return highlighterPromise;
|
|
671
679
|
}
|
|
672
680
|
|
|
673
|
-
|
|
681
|
+
/**
|
|
682
|
+
* Render `code` (of language `lang`) to HTML with shiki's syntax
|
|
683
|
+
* highlighter. `mode` controls which github theme is used so the code
|
|
684
|
+
* block blends with the page chrome on both light and dark surfaces.
|
|
685
|
+
*/
|
|
686
|
+
export async function highlight(
|
|
687
|
+
code: string,
|
|
688
|
+
lang: string,
|
|
689
|
+
mode: "light" | "dark" = "light",
|
|
690
|
+
): Promise<string> {
|
|
674
691
|
const highlighter = await getHighlighter();
|
|
675
692
|
return highlighter.codeToHtml(code, {
|
|
676
693
|
lang: lang,
|
|
677
|
-
theme:
|
|
694
|
+
theme: mode === "dark" ? DARK_THEME : LIGHT_THEME,
|
|
678
695
|
});
|
|
679
696
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
export { AnalyzePackageButton } from "./AnalyzePackageButton";
|
|
2
|
-
export { useRouterClickHandler } from "./click_helper";
|
|
5
|
+
export { useRouterClickHandler, type NavigationClick } from "./click_helper";
|
|
6
|
+
export * from "./Dashboard";
|
|
7
|
+
export * from "./DataAppViewer";
|
|
8
|
+
export * from "./drill";
|
|
9
|
+
export * from "./Environment";
|
|
3
10
|
export * from "./filter";
|
|
11
|
+
export * from "./given";
|
|
4
12
|
export * from "./Home";
|
|
5
13
|
export * from "./Loading";
|
|
14
|
+
export * from "./Materializations";
|
|
6
15
|
export * from "./Model";
|
|
7
16
|
export * from "./Notebook";
|
|
8
17
|
export * from "./Package";
|
|
9
|
-
export * from "./Project";
|
|
10
18
|
export * from "./QueryResult";
|
|
11
19
|
export * from "./RenderedResult";
|
|
12
20
|
export { ServerProvider, useServer } from "./ServerProvider";
|
package/src/components/styles.ts
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { Card, CardContent, CardMedia, styled } from "@mui/material";
|
|
2
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Malloy brand colors — exact hex values from
|
|
8
|
+
* `publisher/packages/app/public/logo.svg`. Use these instead of hardcoding
|
|
9
|
+
* the hex values inline so the brand can be retuned in one place.
|
|
10
|
+
*/
|
|
11
|
+
export const MALLOY_BRAND = {
|
|
12
|
+
teal: "#14b3cb", // light wing of the M
|
|
13
|
+
orange: "#e47404", // right wing of the M
|
|
14
|
+
darkBlue: "#1474a4", // deep shadow of the M
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Accents that extend the logo's three, for the places that need more colors
|
|
19
|
+
* than the brand supplies. The package page gives every kind of content its
|
|
20
|
+
* own, and three kinds became six.
|
|
21
|
+
*
|
|
22
|
+
* Their own family rather than borrowings from the chart series
|
|
23
|
+
* (`theme/defaults.ts`), because the two have opposite constraints. A series
|
|
24
|
+
* color fills a large area and can be light; these sit behind a white icon as a
|
|
25
|
+
* small solid backplate, where the icon has to stay legible. Measured against
|
|
26
|
+
* white: violet 5.5:1, magenta 4.6:1, moss 3.9:1, so all three clear 3:1, the
|
|
27
|
+
* WCAG minimum for a graphical object. The nearest series hues do not: `#aacd85`
|
|
28
|
+
* sage is 1.8:1, `#ec72b8` pink 2.7:1, `#b87ced` violet 2.9:1.
|
|
29
|
+
*
|
|
30
|
+
* These three were picked against the bar, but they are not the only colors it
|
|
31
|
+
* now binds. `CONTENT_TINT` in `Package/ContentTypeIcon.tsx` paints all three of
|
|
32
|
+
* `MALLOY_BRAND` behind glyphs as well, and `ContentTypeIcon.spec.ts` holds two
|
|
33
|
+
* of them to the same 3:1: orange at 3.09:1 and darkBlue at 5.17:1. Orange
|
|
34
|
+
* clears it by 0.09, so retuning it lighter turns that suite red, in a file a
|
|
35
|
+
* brand change would not otherwise open. For those two the bar is a component
|
|
36
|
+
* constraint, not only a brand decision.
|
|
37
|
+
*
|
|
38
|
+
* Teal is the exception at 2.5:1, below the bar and inherited from the logo, so
|
|
39
|
+
* the row it backs carries a white-on-teal glyph that does not meet the
|
|
40
|
+
* standard. Pre-existing, not introduced here. The spec grandfathers it by
|
|
41
|
+
* content type rather than by color, so a new type handed teal still fails.
|
|
42
|
+
*/
|
|
43
|
+
export const MALLOY_ACCENT = {
|
|
44
|
+
violet: "#7c4dcc",
|
|
45
|
+
magenta: "#c2478f",
|
|
46
|
+
moss: "#5c8f3f",
|
|
47
|
+
} as const;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Monospace font stack used by code-like surfaces inside the SDK
|
|
51
|
+
* (file-path labels in PackageItemRow, code blocks, etc.). Matches the
|
|
52
|
+
* `MONO_FONT_FAMILY` defined in the publisher app's theme.
|
|
53
|
+
*/
|
|
54
|
+
export const MONO_FONT_FAMILY =
|
|
55
|
+
'"JetBrains Mono", "ui-monospace", "SFMono-Regular", "Menlo", monospace';
|
|
56
|
+
|
|
3
57
|
export const StyledCard = styled(Card)({
|
|
4
58
|
display: "flex",
|
|
5
59
|
flexDirection: "column",
|
|
@@ -21,21 +75,21 @@ export const StyledCardMedia = styled(CardMedia)({
|
|
|
21
75
|
});
|
|
22
76
|
|
|
23
77
|
// New clean notebook styles
|
|
24
|
-
export const CleanNotebookContainer = styled("div")({
|
|
25
|
-
backgroundColor:
|
|
78
|
+
export const CleanNotebookContainer = styled("div")(({ theme }) => ({
|
|
79
|
+
backgroundColor: theme.palette.background.default,
|
|
26
80
|
padding: "0 8px 0px 8px",
|
|
27
81
|
borderRadius: "12px",
|
|
28
82
|
boxShadow: "none",
|
|
29
83
|
border: "none",
|
|
30
84
|
maxWidth: "1200px",
|
|
31
85
|
margin: "0 auto",
|
|
32
|
-
});
|
|
86
|
+
}));
|
|
33
87
|
|
|
34
|
-
export const CleanNotebookHeader = styled("div")({
|
|
88
|
+
export const CleanNotebookHeader = styled("div")(({ theme }) => ({
|
|
35
89
|
marginBottom: "40px",
|
|
36
90
|
paddingBottom: "24px",
|
|
37
|
-
borderBottom:
|
|
38
|
-
});
|
|
91
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
92
|
+
}));
|
|
39
93
|
|
|
40
94
|
export const CleanNotebookSection = styled("div")({
|
|
41
95
|
marginBottom: "48px",
|
|
@@ -54,40 +108,37 @@ export const CleanNotebookCell = styled("div")({
|
|
|
54
108
|
});
|
|
55
109
|
|
|
56
110
|
export const CleanMetricCard = styled("div")({
|
|
57
|
-
backgroundColor: "
|
|
111
|
+
backgroundColor: "transparent",
|
|
58
112
|
paddingTop: "12px",
|
|
59
113
|
paddingBottom: "2px",
|
|
60
114
|
borderRadius: "8px",
|
|
61
|
-
border: "
|
|
62
|
-
boxShadow: "
|
|
115
|
+
border: "none",
|
|
116
|
+
boxShadow: "none",
|
|
63
117
|
marginBottom: "0",
|
|
64
|
-
transition: "box-shadow 0.2s ease-in-out",
|
|
65
|
-
"&:hover": {
|
|
66
|
-
boxShadow: "0 2px 6px rgba(0, 0, 0, 0.08)",
|
|
67
|
-
},
|
|
68
118
|
});
|
|
69
119
|
|
|
70
|
-
export const CleanCodeBlock = styled("div")({
|
|
71
|
-
backgroundColor: "#f8f9fa",
|
|
120
|
+
export const CleanCodeBlock = styled("div")(({ theme }) => ({
|
|
121
|
+
backgroundColor: theme.palette.mode === "dark" ? "#1e293b" : "#f8f9fa",
|
|
72
122
|
padding: "16px",
|
|
73
123
|
borderRadius: "8px",
|
|
74
|
-
border:
|
|
124
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
75
125
|
fontFamily: "'Monaco', 'Menlo', 'Ubuntu Mono', monospace",
|
|
76
126
|
fontSize: "13px",
|
|
77
127
|
lineHeight: "1.5",
|
|
78
128
|
overflowX: "auto",
|
|
79
|
-
|
|
129
|
+
color: theme.palette.text.primary,
|
|
130
|
+
}));
|
|
80
131
|
|
|
81
|
-
export const CleanActionBar = styled("div")({
|
|
82
|
-
backgroundColor: "#f8f9fa",
|
|
132
|
+
export const CleanActionBar = styled("div")(({ theme }) => ({
|
|
133
|
+
backgroundColor: theme.palette.mode === "dark" ? "#1e293b" : "#f8f9fa",
|
|
83
134
|
padding: "12px 16px",
|
|
84
135
|
borderRadius: "8px",
|
|
85
|
-
border:
|
|
136
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
86
137
|
marginBottom: "16px",
|
|
87
138
|
display: "flex",
|
|
88
139
|
justifyContent: "space-between",
|
|
89
140
|
alignItems: "center",
|
|
90
|
-
});
|
|
141
|
+
}));
|
|
91
142
|
|
|
92
143
|
export const StyledExplorerPage = styled("div")({
|
|
93
144
|
height: "100%",
|
|
@@ -114,18 +165,18 @@ export const StyledExplorerPanel = styled("div")({
|
|
|
114
165
|
});
|
|
115
166
|
|
|
116
167
|
// Package page styles
|
|
117
|
-
export const PackageCard = styled(Card)({
|
|
118
|
-
backgroundColor:
|
|
168
|
+
export const PackageCard = styled(Card)(({ theme }) => ({
|
|
169
|
+
backgroundColor: theme.palette.background.paper,
|
|
119
170
|
padding: "24px",
|
|
120
171
|
borderRadius: "8px",
|
|
121
|
-
border:
|
|
172
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
122
173
|
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.04)",
|
|
123
174
|
height: "100%",
|
|
124
175
|
transition: "box-shadow 0.2s ease-in-out",
|
|
125
176
|
"&:hover": {
|
|
126
177
|
boxShadow: "0 2px 6px rgba(0, 0, 0, 0.08)",
|
|
127
178
|
},
|
|
128
|
-
});
|
|
179
|
+
}));
|
|
129
180
|
|
|
130
181
|
export const PackageCardContent = styled(CardContent)({
|
|
131
182
|
padding: "0",
|
|
@@ -134,16 +185,14 @@ export const PackageCardContent = styled(CardContent)({
|
|
|
134
185
|
},
|
|
135
186
|
});
|
|
136
187
|
|
|
137
|
-
export const PackageSectionTitle = styled("div")({
|
|
138
|
-
fontSize: "
|
|
139
|
-
fontWeight:
|
|
140
|
-
color:
|
|
141
|
-
textTransform: "uppercase",
|
|
142
|
-
letterSpacing: "0.5px",
|
|
188
|
+
export const PackageSectionTitle = styled("div")(({ theme }) => ({
|
|
189
|
+
fontSize: "0.875rem",
|
|
190
|
+
fontWeight: 500,
|
|
191
|
+
color: theme.palette.text.secondary,
|
|
143
192
|
marginBottom: "16px",
|
|
144
193
|
paddingBottom: "8px",
|
|
145
|
-
borderBottom:
|
|
146
|
-
});
|
|
194
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
195
|
+
}));
|
|
147
196
|
|
|
148
197
|
export const PackageContainer = styled("div")({
|
|
149
198
|
padding: "32px",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "bun:test";
|
|
5
|
+
import { readdirSync } from "fs";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
import { DOC_LINKS } from "./docLinks";
|
|
8
|
+
|
|
9
|
+
const REPO_ROOT = join(import.meta.dir, "..", "..", "..", "..");
|
|
10
|
+
const REPO_DOCS_PREFIX =
|
|
11
|
+
"https://github.com/malloydata/publisher/blob/main/docs/";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Every DOC_LINKS entry pointing into this repo names a file that is actually
|
|
15
|
+
* here. These are rendered as links on the Console home page, so a doc renamed
|
|
16
|
+
* or moved without updating the constant ships a 404 to every reader, and
|
|
17
|
+
* nothing else in the build would notice: the value is a string, and a string
|
|
18
|
+
* is as valid wrong as right.
|
|
19
|
+
*
|
|
20
|
+
* What this pins, stated precisely, because the obvious reading is wider than
|
|
21
|
+
* the check: the target exists **in this working tree**. It cannot pin that the
|
|
22
|
+
* URL resolves today, because the URL names `blob/main` and a doc added on a
|
|
23
|
+
* branch is here and not on `main` until that branch merges. That gap is a
|
|
24
|
+
* merge-ordering question, handled by sequencing the pull request, not by a
|
|
25
|
+
* test. What this does catch is the durable half: a rename, a deletion, or a
|
|
26
|
+
* typo, from the moment it happens.
|
|
27
|
+
*
|
|
28
|
+
* Compared against exact basenames rather than with `existsSync`, because macOS
|
|
29
|
+
* is case-insensitive: `dashboards.md` mistyped as `Dashboards.md` passes an
|
|
30
|
+
* existence check on the author's machine and 404s on GitHub, which is
|
|
31
|
+
* case-sensitive. Linux CI would catch it, but only after the author had seen
|
|
32
|
+
* green.
|
|
33
|
+
*/
|
|
34
|
+
describe("DOC_LINKS", () => {
|
|
35
|
+
const repoDocs = Object.entries(DOC_LINKS).filter(([, url]) =>
|
|
36
|
+
url.startsWith(REPO_DOCS_PREFIX),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Guards the filter itself. Were the prefix to drift from the constant, every
|
|
40
|
+
// case below would vanish and the suite would still be green: zero passing
|
|
41
|
+
// assertions reads identically to zero broken links.
|
|
42
|
+
it("covers the in-repo docs", () => {
|
|
43
|
+
expect(repoDocs.length).toBeGreaterThan(0);
|
|
44
|
+
expect(repoDocs.length).toBe(
|
|
45
|
+
Object.values(DOC_LINKS).filter((url) => url.includes("/blob/"))
|
|
46
|
+
.length,
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it.each(repoDocs)("%s resolves to a file in docs/", (_key, url) => {
|
|
51
|
+
const relative = url.slice(REPO_DOCS_PREFIX.length);
|
|
52
|
+
expect(readdirSync(join(REPO_ROOT, "docs"))).toContain(relative);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
// Central list of the Malloy documentation URLs the Publisher UI links to.
|
|
5
|
+
// Keeping them in one place means a docs move only needs updating here, rather
|
|
6
|
+
// than hunting down hardcoded links across the app.
|
|
7
|
+
|
|
8
|
+
const DOCS_BASE = "https://docs.malloydata.dev/documentation";
|
|
9
|
+
const PUBLISHING_BASE = `${DOCS_BASE}/user_guides/publishing`;
|
|
10
|
+
// Publisher's own reference docs, which live in the repo rather than on the
|
|
11
|
+
// docs site. Newer features are documented here first, and for some of them
|
|
12
|
+
// this is the only write-up there is.
|
|
13
|
+
//
|
|
14
|
+
// Pinned to `main`, so a link is live the moment its doc merges and dead until
|
|
15
|
+
// then. `docLinks.spec.ts` checks each target exists in this repo, which catches
|
|
16
|
+
// a rename or a deletion but cannot catch a doc that is here and not yet on
|
|
17
|
+
// `main`; adding a key for a doc still on a branch is a sequencing decision, not
|
|
18
|
+
// something the build can see.
|
|
19
|
+
//
|
|
20
|
+
// One of these is in that state: `choosing-a-surface.md` ships in this change,
|
|
21
|
+
// so its link goes live the moment this merges. The other five are on `main`
|
|
22
|
+
// already, `dashboards.md` as of the dashboards slice landing.
|
|
23
|
+
const REPO_DOCS = "https://github.com/malloydata/publisher/blob/main/docs";
|
|
24
|
+
|
|
25
|
+
export const DOC_LINKS = {
|
|
26
|
+
// Documentation landing page.
|
|
27
|
+
docsHome: `${DOCS_BASE}/`,
|
|
28
|
+
// Setup, deployment, configuration, and the publisher.json package format.
|
|
29
|
+
publishing: `${PUBLISHING_BASE}/publishing`,
|
|
30
|
+
// No-code visual query builder.
|
|
31
|
+
explorer: `${PUBLISHING_BASE}/explorer`,
|
|
32
|
+
// Connect Claude and other AI assistants over MCP.
|
|
33
|
+
mcpAgents: `${PUBLISHING_BASE}/mcp_agents`,
|
|
34
|
+
// Notebooks, dashboards, and HTML data apps, and how to pick between them.
|
|
35
|
+
surfaces: `${REPO_DOCS}/choosing-a-surface.md`,
|
|
36
|
+
// Dashboards declared as tags on a Malloy query.
|
|
37
|
+
dashboards: `${REPO_DOCS}/dashboards.md`,
|
|
38
|
+
// No-build HTML pages served from a package's public/ directory.
|
|
39
|
+
dataApps: `${REPO_DOCS}/html-data-apps.md`,
|
|
40
|
+
// Runtime parameters: filter controls, row-level access, source gates.
|
|
41
|
+
givens: `${REPO_DOCS}/givens.md`,
|
|
42
|
+
// Persisting an expensive source into a table, on demand or on a cron.
|
|
43
|
+
materialization: `${REPO_DOCS}/materialization.md`,
|
|
44
|
+
// Database and query-engine connections.
|
|
45
|
+
connections: `${REPO_DOCS}/connections.md`,
|
|
46
|
+
} as const;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* UI-side value for a given. Mirrors the JS shapes the server accepts for
|
|
6
|
+
* `givens` runtime values, plus `Date` (serialized before send: see
|
|
7
|
+
* `givensToRequest`).
|
|
8
|
+
*
|
|
9
|
+
* Its own module because every control, codec, and hook in the givens path
|
|
10
|
+
* speaks it, and it should not have to be imported from whichever hook happens
|
|
11
|
+
* to be canonical this week.
|
|
12
|
+
*/
|
|
13
|
+
export type GivenValue = string | number | boolean | Date | null;
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
// Filter hooks and types
|
|
2
5
|
export {
|
|
3
6
|
useDimensionFilters,
|
|
@@ -31,3 +34,13 @@ export {
|
|
|
31
34
|
type FilterType,
|
|
32
35
|
type UseDimensionalFilterRangeDataParams,
|
|
33
36
|
} from "./useDimensionalFilterRangeData";
|
|
37
|
+
|
|
38
|
+
// Givens hooks and types
|
|
39
|
+
export { useModelGivens } from "./useModelGivens";
|
|
40
|
+
export { type GivenValue } from "./givenValue";
|
|
41
|
+
export {
|
|
42
|
+
useGivensState,
|
|
43
|
+
type UseGivensStateOptions,
|
|
44
|
+
type UseGivensStateResult,
|
|
45
|
+
} from "./useGivensState";
|
|
46
|
+
export { useSuggestOptions } from "./useSuggestOptions";
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useCallback, useEffect, useState } from "react";
|
|
2
5
|
import {
|
|
3
6
|
DimensionSpec,
|
|
4
7
|
getDimensionKey,
|
|
5
8
|
} from "./useDimensionalFilterRangeData";
|
|
9
|
+
import { escapeMalloyString } from "../utils/malloyString";
|
|
6
10
|
|
|
7
11
|
/**
|
|
8
12
|
* Match types for filtering dimensions
|
|
@@ -75,13 +79,6 @@ export interface UseDimensionFiltersResult {
|
|
|
75
79
|
generateWhereClause: () => string;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
/**
|
|
79
|
-
* Escapes special characters in strings for Malloy queries
|
|
80
|
-
*/
|
|
81
|
-
function escapeMalloyString(value: string): string {
|
|
82
|
-
return value.replace(/'/g, "\\'").replace(/\\/g, "\\\\");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
82
|
/**
|
|
86
83
|
* Formats a value for use in Malloy query
|
|
87
84
|
*/
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useMemo } from "react";
|
|
2
5
|
import {
|
|
3
6
|
DimensionSpec,
|
|
@@ -10,8 +13,8 @@ import { useDimensionFiltersQuery } from "./useDimensionFiltersQuery";
|
|
|
10
13
|
* Configuration for dimensional filters
|
|
11
14
|
*/
|
|
12
15
|
export interface DimensionFiltersConfig {
|
|
13
|
-
/**
|
|
14
|
-
|
|
16
|
+
/** Environment name */
|
|
17
|
+
environment: string;
|
|
15
18
|
/** Package name */
|
|
16
19
|
package: string;
|
|
17
20
|
/** Version ID (optional) */
|
|
@@ -37,7 +40,7 @@ export interface UseDimensionFiltersFromSpecOptions {
|
|
|
37
40
|
* Combined hook that manages dimensional filters, data fetching, and query execution
|
|
38
41
|
* from a single configuration object.
|
|
39
42
|
*
|
|
40
|
-
* @param config - Configuration containing
|
|
43
|
+
* @param config - Configuration containing environment, package, dimension specs, and index limit
|
|
41
44
|
* @param queryLimit - Maximum number of results to return from query (default: 100)
|
|
42
45
|
* @returns All state and methods needed for dimensional filtering UI
|
|
43
46
|
*/
|
|
@@ -69,7 +72,7 @@ export function useDimensionFiltersFromSpec(
|
|
|
69
72
|
// The hook handles multiple source/model combos internally
|
|
70
73
|
const { data, noRowsMatchedFilter, isLoading, isError, error, refetch } =
|
|
71
74
|
useDimensionalFilterRangeData({
|
|
72
|
-
|
|
75
|
+
environment: config.environment,
|
|
73
76
|
package: config.package,
|
|
74
77
|
indexLimit: config.indexLimit,
|
|
75
78
|
dimensionSpecs: config.dimensionSpecs,
|
|
@@ -83,7 +86,7 @@ export function useDimensionFiltersFromSpec(
|
|
|
83
86
|
// Generate the embedded query result (uses primary source/model)
|
|
84
87
|
const { embeddedQueryResult, queryString, executeQuery, canExecute } =
|
|
85
88
|
useDimensionFiltersQuery({
|
|
86
|
-
|
|
89
|
+
environment: config.environment,
|
|
87
90
|
package: config.package,
|
|
88
91
|
model: primaryModel,
|
|
89
92
|
source: primarySource,
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useCallback, useMemo, useState } from "react";
|
|
2
5
|
import { createEmbeddedQueryResult } from "../components/QueryResult";
|
|
3
6
|
import { encodeResourceUri } from "../utils/formatting";
|
|
4
7
|
import { FilterSelection, FilterValuePrimitive } from "./useDimensionFilters";
|
|
8
|
+
import { escapeMalloyString } from "../utils/malloyString";
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Parameters for the useDimensionFiltersQuery hook
|
|
8
12
|
*/
|
|
9
13
|
export interface UseDimensionFiltersQueryParams {
|
|
10
|
-
/**
|
|
11
|
-
|
|
14
|
+
/** Environment name */
|
|
15
|
+
environment: string;
|
|
12
16
|
/** Package name */
|
|
13
17
|
package: string;
|
|
14
18
|
/** Model path */
|
|
@@ -39,13 +43,6 @@ export interface DimensionFiltersQueryResult {
|
|
|
39
43
|
canExecute: boolean;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
/**
|
|
43
|
-
* Escapes special characters in strings for Malloy queries
|
|
44
|
-
*/
|
|
45
|
-
function escapeMalloyString(value: string): string {
|
|
46
|
-
return value.replace(/'/g, "\\'").replace(/\\/g, "\\\\");
|
|
47
|
-
}
|
|
48
|
-
|
|
49
46
|
/**
|
|
50
47
|
* Formats a value for use in Malloy query
|
|
51
48
|
*/
|
|
@@ -218,7 +215,7 @@ function buildFilteredQuery(
|
|
|
218
215
|
* });
|
|
219
216
|
*
|
|
220
217
|
* const { embeddedQueryResult, executeQuery, canExecute } = useDimensionFiltersQuery({
|
|
221
|
-
*
|
|
218
|
+
* environment: "my-environment",
|
|
222
219
|
* package: "my-package",
|
|
223
220
|
* model: "model.malloy",
|
|
224
221
|
* source: "my_source",
|
|
@@ -242,7 +239,7 @@ export function useDimensionFiltersQuery(
|
|
|
242
239
|
params: UseDimensionFiltersQueryParams,
|
|
243
240
|
): DimensionFiltersQueryResult {
|
|
244
241
|
const {
|
|
245
|
-
|
|
242
|
+
environment,
|
|
246
243
|
package: packageName,
|
|
247
244
|
model,
|
|
248
245
|
source,
|
|
@@ -266,11 +263,11 @@ export function useDimensionFiltersQuery(
|
|
|
266
263
|
const resourceUri = useMemo(
|
|
267
264
|
() =>
|
|
268
265
|
encodeResourceUri({
|
|
269
|
-
|
|
266
|
+
environmentName: environment,
|
|
270
267
|
packageName,
|
|
271
268
|
modelPath: model,
|
|
272
269
|
}),
|
|
273
|
-
[
|
|
270
|
+
[environment, packageName, model],
|
|
274
271
|
);
|
|
275
272
|
|
|
276
273
|
// Check if query can be executed
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
1
4
|
import { useMemo } from "react";
|
|
2
5
|
import { useServer } from "../components/ServerProvider";
|
|
3
6
|
import { FilterSelection, FilterValuePrimitive } from "./useDimensionFilters";
|
|
4
7
|
import { useQueryWithApiError } from "./useQueryWithApiError";
|
|
8
|
+
import { escapeMalloyString } from "../utils/malloyString";
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Filter types for dimensions
|
|
@@ -80,8 +84,8 @@ export type DimensionValues = Map<string, DimensionValue[]>;
|
|
|
80
84
|
* Parameters for the useDimensionalFilterRangeData hook
|
|
81
85
|
*/
|
|
82
86
|
export interface UseDimensionalFilterRangeDataParams {
|
|
83
|
-
/**
|
|
84
|
-
|
|
87
|
+
/** Environment name */
|
|
88
|
+
environment: string;
|
|
85
89
|
/** Package name */
|
|
86
90
|
package: string;
|
|
87
91
|
/** List of dimension specifications (each includes source and model) */
|
|
@@ -114,13 +118,6 @@ export interface DimensionalFilterRangeDataResult {
|
|
|
114
118
|
refetch: () => void;
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
/**
|
|
118
|
-
* Escapes special characters in strings for Malloy queries
|
|
119
|
-
*/
|
|
120
|
-
function escapeMalloyString(value: string): string {
|
|
121
|
-
return value.replace(/'/g, "\\'").replace(/\\/g, "\\\\");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
121
|
/**
|
|
125
122
|
* Formats a value for use in Malloy query
|
|
126
123
|
*/
|
|
@@ -611,13 +608,13 @@ function parseIndexQueryResult(
|
|
|
611
608
|
* The hook groups dimension specs by source/model combination and runs separate
|
|
612
609
|
* index queries for each group, then merges the results.
|
|
613
610
|
*
|
|
614
|
-
* @param params - Parameters including
|
|
611
|
+
* @param params - Parameters including environment, package, and dimension specs (each with source/model)
|
|
615
612
|
* @returns Query result with dimension values map, loading state, and error information
|
|
616
613
|
*
|
|
617
614
|
* @example
|
|
618
615
|
* ```tsx
|
|
619
616
|
* const { data, isLoading, error } = useDimensionalFilterRangeData({
|
|
620
|
-
*
|
|
617
|
+
* environment: "my-environment",
|
|
621
618
|
* package: "my-package",
|
|
622
619
|
* dimensionSpecs: [
|
|
623
620
|
* { dimensionName: "category", filterType: "Star", source: "my_source", model: "model.malloy" },
|
|
@@ -632,7 +629,7 @@ export function useDimensionalFilterRangeData(
|
|
|
632
629
|
params: UseDimensionalFilterRangeDataParams,
|
|
633
630
|
): DimensionalFilterRangeDataResult {
|
|
634
631
|
const {
|
|
635
|
-
|
|
632
|
+
environment,
|
|
636
633
|
package: packageName,
|
|
637
634
|
dimensionSpecs,
|
|
638
635
|
versionId,
|
|
@@ -695,7 +692,7 @@ export function useDimensionalFilterRangeData(
|
|
|
695
692
|
const queryResult = useQueryWithApiError({
|
|
696
693
|
queryKey: [
|
|
697
694
|
"dimensionalFilter",
|
|
698
|
-
|
|
695
|
+
environment,
|
|
699
696
|
packageName,
|
|
700
697
|
dimensionSpecs,
|
|
701
698
|
versionId,
|
|
@@ -716,7 +713,7 @@ export function useDimensionalFilterRangeData(
|
|
|
716
713
|
const results = await Promise.all(
|
|
717
714
|
queryConfigs.map(async (config) => {
|
|
718
715
|
const response = await apiClients.models.executeQueryModel(
|
|
719
|
-
|
|
716
|
+
environment,
|
|
720
717
|
packageName,
|
|
721
718
|
config.model,
|
|
722
719
|
{
|