@malloy-publisher/sdk 0.0.382-dev → 0.2.0

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.
Files changed (277) hide show
  1. package/README.md +115 -95
  2. package/TREE_SHAKING.md +16 -11
  3. package/bunfig.toml +7 -0
  4. package/dist/ServerProvider-CTopDUWW.cjs.js +1 -0
  5. package/dist/ServerProvider-DUFPY6Rv.es.js +4072 -0
  6. package/dist/client/api.d.ts +3718 -1507
  7. package/dist/client/configuration.d.ts +1 -1
  8. package/dist/client/index.cjs.js +1 -1
  9. package/dist/client/index.d.ts +1 -1
  10. package/dist/client/index.es.js +85 -59
  11. package/dist/components/Connections/EditConnectionDialog.d.ts +2 -1
  12. package/dist/components/Connections/common.d.ts +8 -2
  13. package/dist/components/Dashboard/Dashboard.d.ts +49 -0
  14. package/dist/components/Dashboard/DashboardTile.d.ts +48 -0
  15. package/dist/components/Dashboard/index.d.ts +2 -0
  16. package/dist/components/DataAppViewer/DataAppViewer.d.ts +23 -0
  17. package/dist/components/DataAppViewer/index.d.ts +1 -0
  18. package/dist/components/Environment/Environment.d.ts +6 -0
  19. package/dist/components/Environment/index.d.ts +2 -0
  20. package/dist/components/Home/AddEnvironmentDialog.d.ts +1 -0
  21. package/dist/components/Home/DeleteEnvironmentDialog.d.ts +5 -0
  22. package/dist/components/Home/EditEnvironmentDialog.d.ts +7 -0
  23. package/dist/components/Home/Home.d.ts +2 -2
  24. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +14 -0
  25. package/dist/components/Materializations/CreateMaterializationDialog.d.ts +10 -0
  26. package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +7 -0
  27. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +7 -0
  28. package/dist/components/Materializations/ManifestView.d.ts +13 -0
  29. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +9 -0
  30. package/dist/components/Materializations/MaterializationRunsList.d.ts +15 -0
  31. package/dist/components/Materializations/Materializations.d.ts +7 -0
  32. package/dist/components/Materializations/ScheduleCard.d.ts +20 -0
  33. package/dist/components/Materializations/SectionLabel.d.ts +10 -0
  34. package/dist/components/Materializations/SetScheduleDialog.d.ts +11 -0
  35. package/dist/components/Materializations/TriggerChip.d.ts +10 -0
  36. package/dist/components/Materializations/cron.d.ts +23 -0
  37. package/dist/components/Materializations/index.d.ts +2 -0
  38. package/dist/components/Materializations/utils.d.ts +46 -0
  39. package/dist/components/Notebook/Notebook.d.ts +47 -4
  40. package/dist/components/Notebook/NotebookCell.d.ts +37 -1
  41. package/dist/components/Notebook/runPlan.d.ts +29 -0
  42. package/dist/components/Notebook/types.d.ts +10 -0
  43. package/dist/components/Package/ContentTypeIcon.d.ts +31 -0
  44. package/dist/components/Package/Package.d.ts +1 -4
  45. package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
  46. package/dist/components/RenderedResult/ResultContainer.d.ts +5 -1
  47. package/dist/components/RenderedResult/renderLogs.d.ts +6 -0
  48. package/dist/components/ResultsDialog.d.ts +6 -1
  49. package/dist/components/ServerProvider.d.ts +28 -4
  50. package/dist/components/click_helper.d.ts +10 -1
  51. package/dist/components/drill/index.d.ts +3 -0
  52. package/dist/components/drill/markDrillableCells.d.ts +55 -0
  53. package/dist/components/drill/resolveDrill.d.ts +139 -0
  54. package/dist/components/drill/useDrill.d.ts +63 -0
  55. package/dist/components/given/GivenInput.d.ts +52 -0
  56. package/dist/components/given/GivensPanel.d.ts +47 -0
  57. package/dist/components/given/filterValue.d.ts +97 -0
  58. package/dist/components/given/index.d.ts +2 -0
  59. package/dist/components/given/paramCodec.d.ts +60 -0
  60. package/dist/components/given/utils.d.ts +17 -0
  61. package/dist/components/highlighter.d.ts +6 -1
  62. package/dist/components/index.d.ts +7 -2
  63. package/dist/components/styles.d.ts +47 -0
  64. package/dist/constants/docLinks.d.ts +12 -0
  65. package/dist/{core-YNpOLuB1.cjs.js → core-hLahnv0W.cjs.js} +1 -1
  66. package/dist/{core-CjeTkq8O.es.js → core-lb28vQkR.es.js} +1 -1
  67. package/dist/github-dark-BKL9xNgN.cjs.js +1 -0
  68. package/dist/github-dark-DenFmJkN.es.js +4 -0
  69. package/dist/hooks/givenValue.d.ts +10 -0
  70. package/dist/hooks/index.d.ts +4 -0
  71. package/dist/hooks/useDimensionFiltersFromSpec.d.ts +3 -3
  72. package/dist/hooks/useDimensionFiltersQuery.d.ts +3 -3
  73. package/dist/hooks/useDimensionalFilterRangeData.d.ts +4 -4
  74. package/dist/hooks/useGivensState.d.ts +64 -0
  75. package/dist/hooks/useModelGivens.d.ts +10 -0
  76. package/dist/hooks/useSuggestOptions.d.ts +78 -0
  77. package/dist/index-DvEanVgc.cjs.js +339 -0
  78. package/dist/{index-DRDu9kIV.es.js → index-txw04ZbN.es.js} +40531 -27964
  79. package/dist/index.cjs.js +1 -1
  80. package/dist/index.d.ts +4 -1
  81. package/dist/index.es.js +79 -48
  82. package/dist/malloy-explorer.css +12 -1
  83. package/dist/sdk.css +1 -1
  84. package/dist/theme/ThemeContext.d.ts +45 -0
  85. package/dist/theme/buildMalloyExplicitTheme.d.ts +34 -0
  86. package/dist/theme/buildTableCssVars.d.ts +25 -0
  87. package/dist/theme/buildVegaThemeOverride.d.ts +16 -0
  88. package/dist/theme/defaults.d.ts +7 -0
  89. package/dist/theme/index.d.ts +8 -0
  90. package/dist/theme/keys.d.ts +20 -0
  91. package/dist/theme/readChartAnnotations.d.ts +23 -0
  92. package/dist/theme/resolveTheme.d.ts +22 -0
  93. package/dist/theme/types.d.ts +70 -0
  94. package/dist/utils/dataAppEmbed.d.ts +44 -0
  95. package/dist/utils/formatting.d.ts +1 -1
  96. package/dist/utils/malloyString.d.ts +7 -0
  97. package/dist/utils/parsing.d.ts +2 -2
  98. package/dist/utils/queryClient.d.ts +5 -0
  99. package/package.json +19 -8
  100. package/src/client-entry.ts +3 -0
  101. package/src/components/AnalyzePackageButton.tsx +9 -3
  102. package/src/components/ApiErrorDisplay.tsx +3 -0
  103. package/src/components/Connections/AddConnectionDialog.tsx +30 -2
  104. package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
  105. package/src/components/Connections/EditConnectionDialog.tsx +33 -4
  106. package/src/components/Connections/common.ts +64 -1
  107. package/src/components/DOMElement/DOMElement.tsx +3 -0
  108. package/src/components/DOMElement/index.ts +3 -0
  109. package/src/components/Dashboard/Dashboard.tsx +398 -0
  110. package/src/components/Dashboard/DashboardTile.tsx +153 -0
  111. package/src/components/Dashboard/index.ts +5 -0
  112. package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
  113. package/src/components/DataAppViewer/index.ts +4 -0
  114. package/src/components/{Project → Environment}/About.tsx +11 -4
  115. package/src/components/Environment/AddPackageDialog.tsx +202 -0
  116. package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
  117. package/src/components/Environment/Connections.tsx +391 -0
  118. package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
  119. package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
  120. package/src/components/Environment/Environment.tsx +89 -0
  121. package/src/components/Environment/Packages.tsx +206 -0
  122. package/src/components/Environment/index.ts +5 -0
  123. package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
  124. package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
  125. package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
  126. package/src/components/Home/Home.tsx +386 -408
  127. package/src/components/Home/index.ts +3 -0
  128. package/src/components/Loading.tsx +3 -0
  129. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
  130. package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
  131. package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
  132. package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
  133. package/src/components/Materializations/ManifestView.tsx +87 -0
  134. package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
  135. package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
  136. package/src/components/Materializations/Materializations.tsx +355 -0
  137. package/src/components/Materializations/ScheduleCard.tsx +231 -0
  138. package/src/components/Materializations/SectionLabel.tsx +30 -0
  139. package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
  140. package/src/components/Materializations/TriggerChip.tsx +44 -0
  141. package/src/components/Materializations/cron.ts +124 -0
  142. package/src/components/Materializations/index.ts +5 -0
  143. package/src/components/Materializations/utils.ts +145 -0
  144. package/src/components/Model/Model.tsx +44 -2
  145. package/src/components/Model/ModelCell.tsx +14 -5
  146. package/src/components/Model/ModelExplorer.tsx +3 -0
  147. package/src/components/Model/ModelExplorerDialog.tsx +4 -1
  148. package/src/components/Model/SourcesExplorer.tsx +9 -6
  149. package/src/components/Model/index.ts +3 -0
  150. package/src/components/Model/useModelData.ts +6 -3
  151. package/src/components/Notebook/Notebook.tsx +475 -339
  152. package/src/components/Notebook/NotebookCell.tsx +264 -25
  153. package/src/components/Notebook/index.ts +3 -0
  154. package/src/components/Notebook/runPlan.spec.ts +155 -0
  155. package/src/components/Notebook/runPlan.ts +67 -0
  156. package/src/components/Notebook/types.ts +14 -0
  157. package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
  158. package/src/components/Package/ContentTypeIcon.tsx +177 -0
  159. package/src/components/Package/FileTreeView.tsx +3 -0
  160. package/src/components/Package/Models.tsx +7 -4
  161. package/src/components/Package/Package.tsx +666 -59
  162. package/src/components/Package/index.ts +3 -0
  163. package/src/components/QueryResult/QueryResult.tsx +17 -8
  164. package/src/components/QueryResult/index.ts +3 -0
  165. package/src/components/RenderedResult/RenderedResult.tsx +685 -67
  166. package/src/components/RenderedResult/ResultContainer.tsx +71 -2
  167. package/src/components/RenderedResult/index.ts +3 -0
  168. package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
  169. package/src/components/RenderedResult/renderLogs.ts +43 -0
  170. package/src/components/ResultsDialog.tsx +13 -1
  171. package/src/components/ServerProvider.tsx +175 -51
  172. package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
  173. package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
  174. package/src/components/Workbook/ModelPicker.tsx +7 -4
  175. package/src/components/Workbook/MutableCell.tsx +10 -5
  176. package/src/components/Workbook/Workbook.tsx +8 -5
  177. package/src/components/Workbook/WorkbookList.tsx +3 -0
  178. package/src/components/Workbook/WorkbookManager.ts +3 -0
  179. package/src/components/Workbook/WorkbookStorage.ts +3 -0
  180. package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
  181. package/src/components/Workbook/index.ts +3 -0
  182. package/src/components/click_helper.ts +17 -1
  183. package/src/components/drill/index.ts +28 -0
  184. package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
  185. package/src/components/drill/markDrillableCells.spec.ts +109 -0
  186. package/src/components/drill/markDrillableCells.ts +314 -0
  187. package/src/components/drill/resolveDrill.spec.ts +449 -0
  188. package/src/components/drill/resolveDrill.ts +375 -0
  189. package/src/components/drill/useDrill.tsx +203 -0
  190. package/src/components/filter/DimensionFilter.tsx +3 -0
  191. package/src/components/filter/index.ts +3 -0
  192. package/src/components/filter/utils.ts +16 -5
  193. package/src/components/given/GivenInput.spec.tsx +689 -0
  194. package/src/components/given/GivenInput.tsx +801 -0
  195. package/src/components/given/GivensPanel.spec.tsx +175 -0
  196. package/src/components/given/GivensPanel.tsx +195 -0
  197. package/src/components/given/filterValue.spec.ts +364 -0
  198. package/src/components/given/filterValue.ts +207 -0
  199. package/src/components/given/index.ts +9 -0
  200. package/src/components/given/paramCodec.spec.ts +857 -0
  201. package/src/components/given/paramCodec.ts +483 -0
  202. package/src/components/given/utils.spec.ts +60 -0
  203. package/src/components/given/utils.ts +79 -0
  204. package/src/components/highlighter.ts +22 -5
  205. package/src/components/index.ts +10 -2
  206. package/src/components/styles.ts +82 -33
  207. package/src/constants/docLinks.spec.ts +54 -0
  208. package/src/constants/docLinks.ts +46 -0
  209. package/src/hooks/givenValue.ts +13 -0
  210. package/src/hooks/index.ts +13 -0
  211. package/src/hooks/useDimensionFilters.ts +4 -7
  212. package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
  213. package/src/hooks/useDimensionFiltersQuery.ts +10 -13
  214. package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
  215. package/src/hooks/useGivensState.spec.ts +449 -0
  216. package/src/hooks/useGivensState.ts +340 -0
  217. package/src/hooks/useModelGivens.ts +29 -0
  218. package/src/hooks/useQueryWithApiError.ts +3 -0
  219. package/src/hooks/useRawQueryData.ts +6 -3
  220. package/src/hooks/useSuggestOptions.spec.ts +112 -0
  221. package/src/hooks/useSuggestOptions.ts +263 -0
  222. package/src/index.ts +10 -1
  223. package/src/react-app-env.d.ts +3 -0
  224. package/src/theme/ThemeContext.tsx +86 -0
  225. package/src/theme/buildMalloyExplicitTheme.ts +61 -0
  226. package/src/theme/buildTableCssVars.spec.ts +67 -0
  227. package/src/theme/buildTableCssVars.ts +67 -0
  228. package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
  229. package/src/theme/buildVegaThemeOverride.ts +47 -0
  230. package/src/theme/defaults.ts +78 -0
  231. package/src/theme/index.ts +11 -0
  232. package/src/theme/keys.ts +32 -0
  233. package/src/theme/readChartAnnotations.spec.ts +58 -0
  234. package/src/theme/readChartAnnotations.ts +69 -0
  235. package/src/theme/resolveTheme.spec.ts +160 -0
  236. package/src/theme/resolveTheme.ts +121 -0
  237. package/src/theme/types.ts +79 -0
  238. package/src/utils/dataAppEmbed.spec.ts +63 -0
  239. package/src/utils/dataAppEmbed.ts +84 -0
  240. package/src/utils/formatting.spec.ts +25 -21
  241. package/src/utils/formatting.ts +11 -7
  242. package/src/utils/malloyString.spec.ts +24 -0
  243. package/src/utils/malloyString.ts +12 -0
  244. package/src/utils/parsing.spec.ts +26 -19
  245. package/src/utils/parsing.ts +11 -6
  246. package/src/utils/queryClient.ts +17 -0
  247. package/test/README.md +141 -0
  248. package/test/setup.ts +29 -0
  249. package/tsconfig.json +12 -1
  250. package/tsconfig.spec.json +22 -0
  251. package/vite.config.ts +3 -0
  252. package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
  253. package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
  254. package/dist/components/Home/AddProjectDialog.d.ts +0 -1
  255. package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
  256. package/dist/components/Home/EditProjectDialog.d.ts +0 -7
  257. package/dist/components/Package/Config.d.ts +0 -5
  258. package/dist/components/Package/Databases.d.ts +0 -5
  259. package/dist/components/Package/Notebooks.d.ts +0 -6
  260. package/dist/components/Project/Project.d.ts +0 -6
  261. package/dist/components/Project/index.d.ts +0 -2
  262. package/dist/index-BOLBP6_i.cjs.js +0 -233
  263. package/src/components/Package/Config.tsx +0 -97
  264. package/src/components/Package/Connections.tsx +0 -373
  265. package/src/components/Package/Databases.tsx +0 -228
  266. package/src/components/Package/Notebooks.tsx +0 -77
  267. package/src/components/Project/AddPackageDialog.tsx +0 -159
  268. package/src/components/Project/Packages.tsx +0 -191
  269. package/src/components/Project/Project.tsx +0 -52
  270. package/src/components/Project/index.ts +0 -2
  271. /package/dist/components/{Project → Environment}/About.d.ts +0 -0
  272. /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
  273. /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
  274. /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
  275. /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
  276. /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
  277. /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
@@ -1,467 +1,445 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { MoreVert } from "@mui/icons-material";
2
- import AnalyticsRoundedIcon from "@mui/icons-material/AnalyticsRounded";
3
- import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded";
4
- import AutoAwesomeRoundedIcon from "@mui/icons-material/AutoAwesomeRounded";
5
- import CodeRoundedIcon from "@mui/icons-material/CodeRounded";
6
- import ExploreRoundedIcon from "@mui/icons-material/ExploreRounded";
7
- import PsychologyRoundedIcon from "@mui/icons-material/PsychologyRounded";
8
- import StorageRoundedIcon from "@mui/icons-material/StorageRounded";
5
+ import FolderOutlinedIcon from "@mui/icons-material/FolderOutlined";
9
6
  import {
10
7
  Box,
11
8
  Button,
12
9
  Card,
13
10
  CardContent,
14
- Chip,
15
11
  Container,
16
12
  Divider,
17
13
  Grid,
18
14
  IconButton,
19
15
  Menu,
20
16
  Stack,
17
+ Tooltip,
21
18
  Typography,
22
19
  } from "@mui/material";
23
20
  import { useState } from "react";
24
- import { Project } from "../../client";
21
+ import { Environment } from "../../client";
25
22
  import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
26
- import { getProjectDescription } from "../../utils/parsing";
23
+ import { serverBaseUrl } from "../../utils/dataAppEmbed";
24
+ import { getEnvironmentDescription } from "../../utils/parsing";
25
+ import { DOC_LINKS } from "../../constants/docLinks";
27
26
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
28
27
  import { Loading } from "../Loading";
29
28
  import { useServer } from "../ServerProvider";
30
- import AddProjectDialog from "./AddProjectDialog";
31
- import DeleteProjectDialog from "./DeleteProjectDialog";
32
- import EditProjectDialog from "./EditProjectDialog";
29
+ import AddEnvironmentDialog from "./AddEnvironmentDialog";
30
+ import DeleteEnvironmentDialog from "./DeleteEnvironmentDialog";
31
+ import EditEnvironmentDialog from "./EditEnvironmentDialog";
33
32
 
34
33
  interface HomeProps {
35
- onClickProject?: (to: string, event?: React.MouseEvent) => void;
34
+ onClickEnvironment?: (to: string, event?: React.MouseEvent) => void;
35
+ }
36
+
37
+ /**
38
+ * What this server can do, in the order someone meets it: exploring first, then
39
+ * the three analytics surfaces a package can hold, then the endpoint agents come
40
+ * in through and the rules that govern all of it. Anything that does not earn a
41
+ * card is named in the closing paragraph rather than crowding this list.
42
+ */
43
+ const FEATURES: Array<{ title: string; body: string; href: string }> = [
44
+ {
45
+ title: "Ad-hoc analysis",
46
+ body: "Browse the semantic sources on this server and build nested queries in Explorer. Every click writes valid Malloy, so metrics stay correct even across joins.",
47
+ href: DOC_LINKS.explorer,
48
+ },
49
+ {
50
+ title: "Notebooks",
51
+ body: "A data story: markdown and live query cells in one file, versioned beside the model it reads. Any givens it imports become a panel of filter controls above the cells.",
52
+ href: DOC_LINKS.surfaces,
53
+ },
54
+ {
55
+ title: "Dashboards",
56
+ body: "A tagged Malloy file is the page. Tags lay out the grid, the filter row is rendered from the query's parameters, and a tagged dimension clicks through to a detail page. No front-end code.",
57
+ href: DOC_LINKS.dashboards,
58
+ },
59
+ {
60
+ title: "Data apps",
61
+ body: "Hand-author an HTML page in a package's public directory and Publisher serves it, backed by that package's models. No build step, and it embeds in a host page.",
62
+ href: DOC_LINKS.dataApps,
63
+ },
64
+ {
65
+ title: "AI data agents",
66
+ body: "One MCP endpoint. Agents discover the sources, compile-check the Malloy they write, and ask well-formed questions instead of guessing at raw tables.",
67
+ href: DOC_LINKS.mcpAgents,
68
+ },
69
+ {
70
+ // Deliberately not "so every caller sees only their rows". Givens are
71
+ // caller-asserted (docs/row-level-access.md), so a row-level filter is not
72
+ // a boundary on its own; `#(authorize)` is the thing that refuses. What is
73
+ // true, and what this says, is that the declarations live in the model, so
74
+ // no surface can define its own.
75
+ title: "Governed access",
76
+ body: "Runtime parameters, row-level filters, and per-source access gates are declared in the model, so every surface reads the same rules rather than reimplementing them.",
77
+ href: DOC_LINKS.givens,
78
+ },
79
+ ];
80
+
81
+ /**
82
+ * Always a new tab. `Home` is exported from the SDK, so it renders inside other
83
+ * people's pages as well as the standalone console, and same-tab navigation
84
+ * there unloads the host application. That includes the API spec, which is
85
+ * served by the Publisher server but not necessarily by the page's own origin.
86
+ * `target` and `rel` are set together so they cannot desynchronise.
87
+ */
88
+ function InlineLink({
89
+ href,
90
+ children,
91
+ }: {
92
+ href: string;
93
+ children: React.ReactNode;
94
+ }) {
95
+ return (
96
+ <Box
97
+ component="a"
98
+ href={href}
99
+ target="_blank"
100
+ rel="noopener noreferrer"
101
+ sx={{ color: "text.primary", textDecoration: "underline" }}
102
+ >
103
+ {children}
104
+ </Box>
105
+ );
36
106
  }
37
107
 
38
- export default function Home({ onClickProject }: HomeProps) {
39
- const { apiClients, mutable } = useServer();
108
+ export default function Home({ onClickEnvironment }: HomeProps) {
109
+ const { apiClients, mutable, server } = useServer();
40
110
 
41
111
  const { data, isSuccess, isError, error } = useQueryWithApiError({
42
- queryKey: ["projects"],
43
- queryFn: () => apiClients.projects.listProjects(),
112
+ queryKey: ["environments"],
113
+ queryFn: () => apiClients.environments.listEnvironments(),
44
114
  });
45
115
 
46
116
  if (isError) {
47
- return <ApiErrorDisplay error={error} context="Projects List" />;
117
+ return <ApiErrorDisplay error={error} context="Environments List" />;
118
+ }
119
+
120
+ if (!isSuccess) {
121
+ return <Loading text="Loading environments..." />;
48
122
  }
49
123
 
50
- if (isSuccess) {
51
- return (
52
- <Container maxWidth="lg" sx={{ py: 4 }}>
53
- {/* Hero Section */}
54
- <Box sx={{ textAlign: "center", mb: 6 }}>
124
+ const environments = data.data ?? [];
125
+
126
+ return (
127
+ <Container maxWidth="md" sx={{ py: 6 }}>
128
+ <Box sx={{ mb: 5 }}>
129
+ <Typography
130
+ variant="h3"
131
+ component="h1"
132
+ sx={{ fontWeight: 500, letterSpacing: "-0.025em", mb: 1 }}
133
+ >
134
+ Publisher
135
+ </Typography>
136
+ <Typography variant="body1" color="text.secondary" sx={{ mb: 3 }}>
137
+ The open-source semantic model server for the Malloy data
138
+ language.
139
+ </Typography>
140
+ <Typography
141
+ variant="body2"
142
+ color="text.secondary"
143
+ sx={{ maxWidth: 720, lineHeight: 1.6 }}
144
+ >
145
+ Define semantic models once and use them everywhere. Publisher
146
+ serves Malloy models over a REST API and a single MCP endpoint,
147
+ so applications, BI tools, and AI agents compose queries against
148
+ the model instead of writing SQL, and the numbers come back right
149
+ by construction.
150
+ </Typography>
151
+ </Box>
152
+
153
+ {/* Two columns at every width above the phone breakpoint, and
154
+ deliberately not the three the environment grid below uses: these
155
+ bodies are prose rather than a name. Measured at 1440px, two across
156
+ gives every card a 410px column and a uniform three lines. Three
157
+ across is narrower than a third of the container, since the grid
158
+ subtracts its gutters, and the bodies then wrap unevenly so the row
159
+ heights stop matching. */}
160
+ <Grid container spacing={4} sx={{ mb: 5 }}>
161
+ {FEATURES.map((feature) => (
162
+ <Grid size={{ xs: 12, sm: 6 }} key={feature.title}>
163
+ <Stack spacing={1}>
164
+ <Typography
165
+ variant="body2"
166
+ component="a"
167
+ href={feature.href}
168
+ target="_blank"
169
+ rel="noopener noreferrer"
170
+ sx={{
171
+ fontWeight: 500,
172
+ color: "text.primary",
173
+ textDecoration: "none",
174
+ "&:hover": { textDecoration: "underline" },
175
+ }}
176
+ >
177
+ {feature.title}
178
+ </Typography>
179
+ <Typography
180
+ variant="body2"
181
+ color="text.secondary"
182
+ sx={{ lineHeight: 1.6 }}
183
+ >
184
+ {feature.body}
185
+ </Typography>
186
+ </Stack>
187
+ </Grid>
188
+ ))}
189
+ </Grid>
190
+
191
+ <Divider sx={{ my: 4 }} />
192
+
193
+ {environments.length > 0 ? (
194
+ <Box sx={{ mb: 4 }}>
55
195
  <Stack
56
196
  direction="row"
57
- justifyContent="center"
58
- alignItems="center"
59
- spacing={1}
60
- sx={{ mb: 2 }}
197
+ justifyContent="space-between"
198
+ alignItems="flex-start"
199
+ sx={{ mb: 3 }}
61
200
  >
62
- <AutoAwesomeRoundedIcon
63
- sx={{ fontSize: 32, color: "primary.main" }}
64
- />
65
- <Typography variant="h3" component="h1" fontWeight={700}>
66
- Publisher
67
- </Typography>
201
+ <Box>
202
+ <Typography
203
+ variant="h5"
204
+ sx={{
205
+ fontWeight: 500,
206
+ letterSpacing: "-0.025em",
207
+ mb: 0.5,
208
+ }}
209
+ >
210
+ Environments
211
+ </Typography>
212
+ <Typography variant="body2" color="text.secondary">
213
+ Published environments available on this server
214
+ </Typography>
215
+ </Box>
216
+ {mutable && <AddEnvironmentDialog />}
68
217
  </Stack>
218
+ <Grid container spacing={2}>
219
+ {environments.map((environment) => (
220
+ <Grid
221
+ size={{ xs: 12, sm: 6, md: 4 }}
222
+ key={environment.name}
223
+ >
224
+ <EnvironmentCard
225
+ environment={environment}
226
+ onClickEnvironment={onClickEnvironment}
227
+ />
228
+ </Grid>
229
+ ))}
230
+ </Grid>
231
+ </Box>
232
+ ) : (
233
+ <Box sx={{ mb: 4 }}>
69
234
  <Typography
70
235
  variant="h5"
71
- color="text.secondary"
72
- sx={{ mb: 3, maxWidth: 600, mx: "auto" }}
236
+ sx={{ fontWeight: 500, letterSpacing: "-0.025em", mb: 1 }}
73
237
  >
74
- The open-source semantic model server for the Malloy data
75
- language
238
+ Get started
76
239
  </Typography>
77
240
  <Typography
78
- variant="body1"
241
+ variant="body2"
79
242
  color="text.secondary"
80
- sx={{ maxWidth: 800, mx: "auto" }}
243
+ sx={{ mb: 3, maxWidth: 600 }}
81
244
  >
82
- Define semantic models once — and use them everywhere.
83
- Publisher serves Malloy models through clean APIs, enabling
84
- consistent, interpretable, and AI-ready data access for tools,
85
- applications, and agents.
245
+ Create your first Malloy environment to start exploring
246
+ semantic models and building data experiences.
86
247
  </Typography>
87
- </Box>
88
-
89
- {/* Feature Cards */}
90
- <Grid container spacing={3} sx={{ mb: 6 }}>
91
- <Grid size={{ xs: 12, md: 4 }}>
92
- <Card
93
- variant="outlined"
94
- onClick={() => {
95
- window.open(
96
- "https://github.com/malloydata/publisher/blob/main/README.md#ad-hoc-data-analysis",
97
- "_blank",
98
- );
99
- }}
100
- sx={{
101
- height: "100%",
102
- cursor: "pointer",
103
- transition: "all 0.2s ease",
104
- "&:hover": {
105
- transform: "translateY(-2px)",
106
- boxShadow: 2,
107
- },
108
- }}
109
- >
110
- <CardContent sx={{ p: 3 }}>
111
- <Stack
112
- direction="row"
113
- alignItems="center"
114
- spacing={1}
115
- sx={{ mb: 2 }}
116
- >
117
- <AnalyticsRoundedIcon
118
- sx={{ color: "info.main", fontSize: 28 }}
119
- />
120
- <Typography variant="h6" fontWeight={600}>
121
- Ad Hoc Analysis
122
- </Typography>
123
- </Stack>
124
- <Typography
125
- variant="body2"
126
- color="text.secondary"
127
- sx={{ mb: 2 }}
128
- >
129
- Use Explorer, a visual query builder that allows
130
- analysts to browse semantic sources, build queries,
131
- and run nested logic — all without writing code.
132
- </Typography>
133
- <Chip
134
- label="No-code"
135
- size="small"
136
- color="primary"
137
- variant="outlined"
138
- />
139
- </CardContent>
140
- </Card>
141
- </Grid>
142
-
143
- <Grid size={{ xs: 12, md: 4 }}>
144
- <Card
145
- variant="outlined"
146
- onClick={() => {
147
- window.open(
148
- "https://github.com/malloydata/publisher/blob/main/README.md#notebook-based-dashboards",
149
- "_blank",
150
- );
151
- }}
152
- sx={{
153
- height: "100%",
154
- cursor: "pointer",
155
- transition: "all 0.2s ease",
156
- "&:hover": {
157
- transform: "translateY(-2px)",
158
- boxShadow: 2,
159
- },
160
- }}
161
- >
162
- <CardContent sx={{ p: 3 }}>
163
- <Stack
164
- direction="row"
165
- alignItems="center"
166
- spacing={1}
167
- sx={{ mb: 2 }}
168
- >
169
- <CodeRoundedIcon
170
- sx={{ color: "warning.main", fontSize: 28 }}
171
- />
172
- <Typography variant="h6" fontWeight={600}>
173
- Notebook Dashboards
174
- </Typography>
175
- </Stack>
176
- <Typography
177
- variant="body2"
178
- color="text.secondary"
179
- sx={{ mb: 2 }}
180
- >
181
- Create shareable, code-first dashboards using Malloy
182
- notebooks. Include text, charts, and reusable views —
183
- all versioned alongside your models.
184
- </Typography>
185
- <Chip
186
- label="Versioned"
187
- size="small"
188
- color="warning"
189
- variant="outlined"
190
- />
191
- </CardContent>
192
- </Card>
193
- </Grid>
194
-
195
- <Grid size={{ xs: 12, md: 4 }}>
196
- <Card
197
- variant="outlined"
198
- onClick={() => {
199
- window.open(
200
- "https://github.com/malloydata/publisher/blob/main/README.md#mcp-based-ai-data-agents",
201
- "_blank",
202
- );
203
- }}
204
- sx={{
205
- height: "100%",
206
- cursor: "pointer",
207
- transition: "all 0.2s ease",
208
- "&:hover": {
209
- transform: "translateY(-2px)",
210
- boxShadow: 2,
211
- },
212
- }}
213
- >
214
- <CardContent sx={{ p: 3 }}>
215
- <Stack
216
- direction="row"
217
- alignItems="center"
218
- spacing={1}
219
- sx={{ mb: 2 }}
220
- >
221
- <PsychologyRoundedIcon
222
- sx={{ color: "success.main", fontSize: 28 }}
223
- />
224
- <Typography variant="h6" fontWeight={600}>
225
- AI Data Agents
226
- </Typography>
227
- </Stack>
228
- <Typography
229
- variant="body2"
230
- color="text.secondary"
231
- sx={{ mb: 2 }}
232
- >
233
- Expose your semantic models via the Model Context
234
- Protocol (MCP), enabling AI agents to discover
235
- sources and ask well-formed questions.
236
- </Typography>
237
- <Chip
238
- label="AI-Ready"
239
- size="small"
240
- color="success"
241
- variant="outlined"
242
- />
243
- </CardContent>
244
- </Card>
245
- </Grid>
246
- </Grid>
247
-
248
- <Divider sx={{ my: 4 }} />
249
-
250
- {/* Project Selection Section */}
251
- {data.data.length > 0 ? (
252
- <>
253
- <Box sx={{ textAlign: "center", mb: 4 }}>
254
- <Stack
255
- direction="row"
256
- justifyContent="center"
257
- alignItems="center"
258
- spacing={1}
259
- sx={{ mb: 2 }}
260
- >
261
- <StorageRoundedIcon
262
- sx={{ color: "primary.main", fontSize: 24 }}
263
- />
264
- <Typography variant="h4" fontWeight={600}>
265
- Select a Project
266
- </Typography>
267
- </Stack>
268
- <Typography variant="body1" color="text.secondary">
269
- Choose a project to explore its semantic models and
270
- start analyzing your data
271
- </Typography>
272
- {mutable && <AddProjectDialog />}
273
- </Box>
274
- <Grid container spacing={3} justifyContent="center">
275
- {data.data.map((project) => (
276
- <Grid
277
- size={{ xs: 12, sm: 6, md: 4 }}
278
- key={project.name}
279
- >
280
- <ProjectCard
281
- project={project}
282
- onClickProject={onClickProject}
283
- />
284
- </Grid>
285
- ))}
286
- </Grid>
287
- </>
288
- ) : (
289
- <Box sx={{ textAlign: "center", mb: 4 }}>
290
- <Stack
291
- direction="row"
292
- justifyContent="center"
293
- alignItems="center"
294
- spacing={1}
295
- sx={{ mb: 2 }}
296
- >
297
- <StorageRoundedIcon
298
- sx={{ color: "primary.main", fontSize: 24 }}
299
- />
300
- <Typography variant="h4" fontWeight={600}>
301
- Get Started
302
- </Typography>
303
- </Stack>
304
- <Typography
305
- variant="body1"
306
- color="text.secondary"
307
- sx={{ mb: 3 }}
308
- >
309
- No projects found. Create your first Malloy project to
310
- start exploring semantic models and building data
311
- experiences.
312
- </Typography>
313
- {mutable ? (
314
- <AddProjectDialog />
315
- ) : (
316
- <Button
317
- variant="contained"
318
- size="large"
319
- color="primary"
320
- startIcon={<AutoAwesomeRoundedIcon />}
321
- href="https://github.com/malloydata/publisher/blob/main/README.md#server-configuration"
322
- target="_blank"
323
- rel="noopener noreferrer"
324
- >
325
- Learn How to Create Models
326
- </Button>
327
- )}
328
- </Box>
329
- )}
330
-
331
- {/* Footer Section */}
332
- <Box
333
- sx={{
334
- textAlign: "center",
335
- mt: 6,
336
- pt: 4,
337
- borderTop: 1,
338
- borderColor: "divider",
339
- }}
340
- >
341
- <Typography variant="body2" color="text.secondary">
342
- Publisher is built on fully open infrastructure and designed
343
- for the AI era. Join the{" "}
344
- <a
345
- href="https://join.slack.com/t/malloy-community/shared_invite/zt-1kgfwgi5g-CrsdaRqs81QY67QW0~t_uw"
248
+ {mutable ? (
249
+ <AddEnvironmentDialog />
250
+ ) : (
251
+ <Button
252
+ variant="contained"
253
+ color="primary"
254
+ href={DOC_LINKS.publishing}
346
255
  target="_blank"
347
256
  rel="noopener noreferrer"
348
- style={{
349
- color: "primary.main",
350
- textDecoration: "underline",
351
- }}
352
257
  >
353
- Malloy Slack community
354
- </a>{" "}
355
- to ask questions, share ideas, and contribute to the future of
356
- data modeling.
357
- </Typography>
258
+ Learn how to create models
259
+ </Button>
260
+ )}
358
261
  </Box>
359
- </Container>
360
- );
361
- } else {
362
- return <Loading text="Loading projects..." />;
363
- }
262
+ )}
263
+
264
+ <Divider sx={{ my: 4 }} />
265
+
266
+ <Typography
267
+ variant="body2"
268
+ color="text.secondary"
269
+ sx={{ maxWidth: 720, lineHeight: 1.6 }}
270
+ >
271
+ {/* Six of the ten types in the api-doc.yaml enum. connections.md
272
+ names eight. Two of the six named here, mysql and trino,
273
+ appear in connections.md exactly once, in the parenthetical that
274
+ ends "etc."; Databricks and MotherDuck it never names at all. "And more"
275
+ rather than a full list, because a list that reads as complete
276
+ while omitting Databricks is worse than a short one that says
277
+ it is short. */}
278
+ Also here:{" "}
279
+ <InlineLink href={DOC_LINKS.connections}>connections</InlineLink> to
280
+ BigQuery, Snowflake, Postgres, MySQL, Trino, DuckDB and more;{" "}
281
+ <InlineLink href={DOC_LINKS.materialization}>
282
+ materialized tables
283
+ </InlineLink>{" "}
284
+ built on demand or on a schedule; and a{" "}
285
+ {/* Built from the configured server rather than written as
286
+ "/api-doc.html". The spec is a static file off the Publisher
287
+ server's root, and an SDK consumer's page origin need not be
288
+ that server: a root-relative href resolves against the host and
289
+ 404s. serverBaseUrl exists for exactly this. */}
290
+ <InlineLink href={`${serverBaseUrl(server)}/api-doc.html`}>
291
+ REST API
292
+ </InlineLink>{" "}
293
+ that does everything this console does.
294
+ </Typography>
295
+
296
+ <Typography
297
+ variant="body2"
298
+ color="text.secondary"
299
+ sx={{ maxWidth: 720, lineHeight: 1.6, mt: 2 }}
300
+ >
301
+ Publisher is built on fully open infrastructure and designed for the
302
+ AI era. Join the{" "}
303
+ <InlineLink href="https://join.slack.com/t/malloy-community/shared_invite/zt-1kgfwgi5g-CrsdaRqs81QY67QW0~t_uw">
304
+ Malloy Slack community
305
+ </InlineLink>{" "}
306
+ to ask questions, share ideas, and contribute.
307
+ </Typography>
308
+ </Container>
309
+ );
364
310
  }
365
- function ProjectCard({
366
- project,
367
- onClickProject,
311
+
312
+ function EnvironmentCard({
313
+ environment,
314
+ onClickEnvironment,
368
315
  }: {
369
- project: Project;
370
- onClickProject: (to: string, event?: React.MouseEvent) => void;
316
+ environment: Environment;
317
+ onClickEnvironment?: (to: string, event?: React.MouseEvent) => void;
371
318
  }) {
372
319
  const { mutable } = useServer();
373
320
  const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
374
- const isMenuOpen = Boolean(menuAnchorEl);
375
- const openMenu = (event: React.MouseEvent<HTMLElement>) => {
321
+ const menuOpen = Boolean(menuAnchorEl);
322
+
323
+ const description = getEnvironmentDescription(environment.readme);
324
+
325
+ const handleClick = (event: React.MouseEvent) => {
326
+ if (environment.name && onClickEnvironment) {
327
+ onClickEnvironment(`/${environment.name}/`, event);
328
+ }
329
+ };
330
+
331
+ const handleMenuClick = (event: React.MouseEvent<HTMLElement>) => {
332
+ event.stopPropagation();
376
333
  setMenuAnchorEl(event.currentTarget);
377
334
  };
378
- const closeMenu = () => {
335
+
336
+ const handleMenuClose = () => {
379
337
  setMenuAnchorEl(null);
380
338
  };
339
+
381
340
  return (
382
- <div>
383
- <Card
384
- variant="outlined"
385
- sx={{
386
- height: "100%",
387
- transition: "all 0.2s ease",
388
- "&:hover": {
389
- transform: "translateY(-2px)",
390
- boxShadow: 2,
391
- borderColor: "primary.main",
392
- },
393
- }}
394
- >
395
- {mutable && (
396
- <>
397
- <IconButton
398
- aria-controls={isMenuOpen ? "project-menu" : undefined}
399
- aria-haspopup="true"
400
- aria-expanded={isMenuOpen ? "true" : undefined}
401
- onClick={openMenu}
402
- sx={{ position: "absolute", top: 8, right: 8 }}
403
- >
404
- <MoreVert fontSize="small" />
405
- </IconButton>
406
- <Menu
407
- id="project-menu"
408
- aria-haspopup="true"
409
- aria-expanded={isMenuOpen ? "true" : undefined}
410
- open={isMenuOpen}
411
- anchorEl={menuAnchorEl}
412
- onClose={closeMenu}
413
- disableRestoreFocus
414
- anchorOrigin={{
415
- vertical: "top",
416
- horizontal: "left",
417
- }}
418
- transformOrigin={{
419
- vertical: "top",
420
- horizontal: "right",
421
- }}
422
- >
423
- <EditProjectDialog
424
- project={project}
425
- onCloseDialog={closeMenu}
426
- />
427
- <DeleteProjectDialog
428
- project={project}
429
- onCloseDialog={closeMenu}
430
- />
431
- </Menu>
432
- </>
433
- )}
434
- <CardContent sx={{ p: 3, textAlign: "center" }}>
435
- <ExploreRoundedIcon
436
- sx={{
437
- fontSize: 48,
438
- color: "primary.main",
439
- mb: 2,
440
- }}
441
- />
442
- <Typography variant="h6" fontWeight={600} gutterBottom>
443
- {project.name}
444
- </Typography>
445
- <Typography
446
- variant="body2"
447
- color="text.secondary"
448
- sx={{ mb: 2, minHeight: "60px" }}
449
- >
450
- {getProjectDescription(project.readme)}
451
- </Typography>
452
- <Button
453
- variant="contained"
454
- color="secondary"
455
- endIcon={<ArrowForwardRoundedIcon />}
456
- fullWidth
457
- onClick={(event) =>
458
- onClickProject(`/${project.name}/`, event)
459
- }
341
+ <Card
342
+ variant="outlined"
343
+ onClick={handleClick}
344
+ sx={{
345
+ height: "100%",
346
+ cursor: "pointer",
347
+ borderRadius: 3,
348
+ borderColor: "divider",
349
+ boxShadow: "none",
350
+ transition: "all 0.2s ease-in-out",
351
+ "&:hover": { boxShadow: 2, borderColor: "primary.main" },
352
+ }}
353
+ >
354
+ <CardContent sx={{ p: 2.5, "&:last-child": { pb: 2.5 } }}>
355
+ <Box
356
+ sx={{
357
+ display: "flex",
358
+ alignItems: "flex-start",
359
+ gap: 1.5,
360
+ }}
361
+ >
362
+ <Box
363
+ sx={(theme) => ({
364
+ width: 36,
365
+ height: 36,
366
+ borderRadius: 1.5,
367
+ bgcolor:
368
+ theme.palette.mode === "dark"
369
+ ? "rgba(255, 255, 255, 0.08)"
370
+ : "grey.100",
371
+ display: "flex",
372
+ alignItems: "center",
373
+ justifyContent: "center",
374
+ flexShrink: 0,
375
+ color: "text.primary",
376
+ })}
460
377
  >
461
- Open Project
462
- </Button>
463
- </CardContent>
464
- </Card>
465
- </div>
378
+ <FolderOutlinedIcon sx={{ fontSize: 20 }} />
379
+ </Box>
380
+ <Box sx={{ flex: 1, minWidth: 0 }}>
381
+ <Typography
382
+ variant="subtitle1"
383
+ component="h6"
384
+ noWrap
385
+ sx={{ fontWeight: 600, mb: 0.5 }}
386
+ >
387
+ {environment.name}
388
+ </Typography>
389
+ <Tooltip title={description} followCursor enterDelay={1000}>
390
+ <Typography
391
+ variant="body2"
392
+ color="text.secondary"
393
+ sx={{
394
+ overflow: "hidden",
395
+ textOverflow: "ellipsis",
396
+ display: "-webkit-box",
397
+ WebkitLineClamp: 2,
398
+ WebkitBoxOrient: "vertical",
399
+ lineHeight: 1.5,
400
+ }}
401
+ >
402
+ {description}
403
+ </Typography>
404
+ </Tooltip>
405
+ </Box>
406
+ {mutable && (
407
+ <>
408
+ <IconButton
409
+ size="small"
410
+ onClick={handleMenuClick}
411
+ aria-label={`Environment actions for ${environment.name}`}
412
+ sx={{ flexShrink: 0, mt: -0.5, mr: -0.5 }}
413
+ >
414
+ <MoreVert fontSize="small" />
415
+ </IconButton>
416
+ <Menu
417
+ anchorEl={menuAnchorEl}
418
+ open={menuOpen}
419
+ onClose={handleMenuClose}
420
+ onClick={(e) => e.stopPropagation()}
421
+ anchorOrigin={{
422
+ vertical: "bottom",
423
+ horizontal: "right",
424
+ }}
425
+ transformOrigin={{
426
+ vertical: "top",
427
+ horizontal: "right",
428
+ }}
429
+ >
430
+ <EditEnvironmentDialog
431
+ environment={environment}
432
+ onCloseDialog={handleMenuClose}
433
+ />
434
+ <DeleteEnvironmentDialog
435
+ environment={environment}
436
+ onCloseDialog={handleMenuClose}
437
+ />
438
+ </Menu>
439
+ </>
440
+ )}
441
+ </Box>
442
+ </CardContent>
443
+ </Card>
466
444
  );
467
445
  }