@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
@@ -0,0 +1,214 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import OpenInNewIcon from "@mui/icons-material/OpenInNew";
5
+ import { Box, IconButton, Stack, Tooltip, Typography } from "@mui/material";
6
+ import { useEffect, useMemo, useRef, useState } from "react";
7
+ import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
8
+ import { useServer } from "../ServerProvider";
9
+ import { MONO_FONT_FAMILY } from "../styles";
10
+ import { parseResourceUri } from "../../utils/formatting";
11
+ import {
12
+ isPublisherResizeMessage,
13
+ packageFileUrl,
14
+ } from "../../utils/dataAppEmbed";
15
+
16
+ interface DataAppViewerProps {
17
+ resourceUri: string;
18
+ }
19
+
20
+ function parseDataAppResource(resourceUri: string) {
21
+ try {
22
+ const { environmentName, packageName, modelPath } =
23
+ parseResourceUri(resourceUri);
24
+ if (!environmentName || !packageName || !modelPath) return null;
25
+ return { environmentName, packageName, dataAppPath: modelPath };
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Renders an in-package HTML data app (from the Publisher static-file route)
33
+ * inside an iframe, wrapped in light SPA chrome — title, breadcrumb-ish
34
+ * label, and an "open standalone" escape hatch.
35
+ *
36
+ * The iframe `src` points at the Publisher worker's standalone URL on the
37
+ * data origin (derived from `useServer().server`, which may differ from
38
+ * the SPA origin in multi-host deployments). The app's `publisher.js`
39
+ * runtime postMessages `{ type: "publisher:resize", height }` as content
40
+ * height changes; we listen and resize the iframe to match so embedded
41
+ * dashboards don't get a nested scrollbar.
42
+ *
43
+ * Full-screen apps (e.g. slide decks) can opt out of content-height sizing
44
+ * with `<meta name="publisher:fit" content="viewport">`, surfaced as
45
+ * `DataApp.fit === "viewport"`. The iframe then fills the available viewport
46
+ * height (matching the standalone view) instead of collapsing to the app's
47
+ * near-zero reported content height.
48
+ */
49
+ export default function DataAppViewer({ resourceUri }: DataAppViewerProps) {
50
+ const { server, apiClients } = useServer();
51
+ const parsed = parseDataAppResource(resourceUri);
52
+ const environmentName = parsed?.environmentName ?? "";
53
+ const packageName = parsed?.packageName ?? "";
54
+ const dataAppPath = parsed?.dataAppPath ?? "";
55
+
56
+ const standaloneUrl = useMemo(
57
+ () =>
58
+ packageFileUrl({
59
+ server,
60
+ environmentName,
61
+ packageName,
62
+ path: dataAppPath,
63
+ }),
64
+ [server, environmentName, packageName, dataAppPath],
65
+ );
66
+
67
+ // Use the /data-apps endpoint to grab the <title> for the header. Any error
68
+ // here (older Publisher without /data-apps, transient network blip, 5xx) is
69
+ // non-fatal — `title` falls back to `dataAppPath` and the iframe still
70
+ // renders. The app itself is loaded via the iframe `src`, not from this
71
+ // query, so blocking the viewer on a metadata lookup would be wrong.
72
+ const dataAppsQuery = useQueryWithApiError({
73
+ queryKey: ["data-apps", environmentName, packageName],
74
+ queryFn: () =>
75
+ apiClients.dataApps.listDataApps(environmentName, packageName),
76
+ enabled: !!parsed,
77
+ });
78
+ const dataAppMeta = dataAppsQuery.data?.data?.find(
79
+ (a) => a.path === dataAppPath,
80
+ );
81
+ const title = dataAppMeta?.title ?? dataAppPath;
82
+ // Full-screen apps opt in via <meta name="publisher:fit" content="viewport">
83
+ // (surfaced as DataApp.fit by the /data-apps listing). In fill mode the
84
+ // iframe fills the available viewport height instead of being sized to the
85
+ // app's reported content height: a viewport-filling deck has ~no content
86
+ // height to report, so the default auto-size would clip it. An ordinary
87
+ // content-driven app keeps auto-sizing.
88
+ const fillViewport = dataAppMeta?.fit === "viewport";
89
+
90
+ const iframeRef = useRef<HTMLIFrameElement | null>(null);
91
+ // Start small so the iframe doesn't pre-commit space before the first
92
+ // resize message; the runtime postMessages the real content height
93
+ // within a frame of load.
94
+ const [iframeHeight, setIframeHeight] = useState<number>(120);
95
+
96
+ useEffect(() => {
97
+ // Fill mode pins the iframe to 100%, so content-height resize messages are
98
+ // irrelevant; skip subscribing (and the per-message re-renders) until the
99
+ // app is in content-height mode.
100
+ if (fillViewport) return;
101
+ function onMessage(e: MessageEvent) {
102
+ if (!isPublisherResizeMessage(e.data)) return;
103
+ if (e.source !== iframeRef.current?.contentWindow) return;
104
+ if (e.data.height > 0) {
105
+ setIframeHeight(Math.ceil(e.data.height));
106
+ }
107
+ }
108
+ window.addEventListener("message", onMessage);
109
+ return () => window.removeEventListener("message", onMessage);
110
+ }, [fillViewport]);
111
+
112
+ if (!parsed) {
113
+ return (
114
+ <Box sx={{ p: 3, maxWidth: 1200, mx: "auto" }}>
115
+ <Typography variant="h6" sx={{ fontWeight: 600 }}>
116
+ Can&apos;t open data app
117
+ </Typography>
118
+ <Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
119
+ This data app link is missing an environment, package, or path:
120
+ <Box
121
+ component="span"
122
+ sx={{ fontFamily: MONO_FONT_FAMILY, ml: 1 }}
123
+ >
124
+ {resourceUri}
125
+ </Box>
126
+ </Typography>
127
+ </Box>
128
+ );
129
+ }
130
+
131
+ return (
132
+ <Box
133
+ sx={{
134
+ p: 3,
135
+ // Fill mode fills the available height of DataAppViewer's ancestor,
136
+ // so it must render inside a height-constrained container. The
137
+ // Publisher app provides one (MainPage's 100dvh flex chain); an SDK
138
+ // consumer embedding DataAppViewer should give it a bounded-height
139
+ // parent.
140
+ ...(fillViewport
141
+ ? { height: "100%", display: "flex", flexDirection: "column" }
142
+ : { maxWidth: 1200, mx: "auto" }),
143
+ }}
144
+ >
145
+ <Stack
146
+ direction="row"
147
+ alignItems="baseline"
148
+ spacing={1}
149
+ sx={{ mb: 1, flexShrink: 0 }}
150
+ >
151
+ <Typography
152
+ variant="h6"
153
+ sx={{ fontWeight: 600, letterSpacing: "-0.025em" }}
154
+ >
155
+ {title}
156
+ </Typography>
157
+ <Typography
158
+ variant="caption"
159
+ color="text.secondary"
160
+ sx={{ fontFamily: MONO_FONT_FAMILY }}
161
+ >
162
+ {dataAppPath}
163
+ </Typography>
164
+ <Box sx={{ flex: 1 }} />
165
+ <Tooltip title="Open standalone in new tab">
166
+ <IconButton
167
+ size="small"
168
+ href={standaloneUrl}
169
+ target="_blank"
170
+ rel="noopener noreferrer"
171
+ aria-label="Open standalone in new tab"
172
+ sx={{ color: "text.secondary" }}
173
+ >
174
+ <OpenInNewIcon fontSize="small" />
175
+ </IconButton>
176
+ </Tooltip>
177
+ </Stack>
178
+ <Box
179
+ sx={{
180
+ border: "1px solid",
181
+ borderColor: "divider",
182
+ borderRadius: 1.5,
183
+ overflow: "hidden",
184
+ backgroundColor: "background.paper",
185
+ // Fill mode: grow to consume the remaining viewport height (the
186
+ // SPA gives DataAppViewer a 100dvh flex ancestor) so the iframe
187
+ // below can be 100% tall. minHeight:0 lets this flex child
188
+ // actually shrink/grow instead of overflowing its parent.
189
+ ...(fillViewport ? { flex: 1, minHeight: 0 } : {}),
190
+ }}
191
+ >
192
+ <iframe
193
+ ref={iframeRef}
194
+ src={standaloneUrl}
195
+ title={title}
196
+ // allow-same-origin so the iframe can use cookies for the
197
+ // Publisher API. allow-scripts so the dashboard's JS runs.
198
+ // allow-forms so dropdown/filter forms work. Intentionally
199
+ // NOT allowing top-navigation or popups.
200
+ sandbox="allow-scripts allow-same-origin allow-forms"
201
+ style={{
202
+ display: "block",
203
+ width: "100%",
204
+ // Fill mode pins the iframe to the available height so the
205
+ // deck's own 100vh resolves against a real viewport. Otherwise
206
+ // track the content height reported via publisher:resize.
207
+ height: fillViewport ? "100%" : iframeHeight,
208
+ border: 0,
209
+ }}
210
+ />
211
+ </Box>
212
+ </Box>
213
+ );
214
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ export { default as DataAppViewer } from "./DataAppViewer";
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { Box, Button } from "@mui/material";
2
5
  import Markdown from "markdown-to-jsx";
3
6
  import { useState } from "react";
@@ -16,14 +19,15 @@ interface AboutProps {
16
19
  }
17
20
 
18
21
  export default function About({ resourceUri }: AboutProps) {
19
- const { projectName } = parseResourceUri(resourceUri);
22
+ const { environmentName } = parseResourceUri(resourceUri);
20
23
  const { apiClients } = useServer();
21
24
  const [expanded, setExpanded] = useState(false);
22
25
  const wordLimit = 90;
23
26
 
24
27
  const { data, isSuccess, isError, error } = useQueryWithApiError({
25
- queryKey: ["about", projectName],
26
- queryFn: () => apiClients.projects.getProject(projectName, false),
28
+ queryKey: ["about", environmentName],
29
+ queryFn: () =>
30
+ apiClients.environments.getEnvironment(environmentName, false),
27
31
  });
28
32
 
29
33
  const readmeContent = data?.data?.readme || "";
@@ -93,7 +97,10 @@ export default function About({ resourceUri }: AboutProps) {
93
97
  </PackageCard>
94
98
  )}
95
99
  {isError && (
96
- <ApiErrorDisplay error={error} context={`${projectName} > About`} />
100
+ <ApiErrorDisplay
101
+ error={error}
102
+ context={`${environmentName} > About`}
103
+ />
97
104
  )}
98
105
  </>
99
106
  );
@@ -0,0 +1,202 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Add } from "@mui/icons-material";
5
+ import {
6
+ Box,
7
+ Button,
8
+ Dialog,
9
+ DialogActions,
10
+ DialogContent,
11
+ DialogTitle,
12
+ Snackbar,
13
+ Stack,
14
+ TextField,
15
+ Typography,
16
+ } from "@mui/material";
17
+ import { useQueryClient } from "@tanstack/react-query";
18
+ import React, { useState } from "react";
19
+ import { Package } from "../../client";
20
+ import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
21
+ import { parseResourceUri } from "../../utils/formatting";
22
+ import { DOC_LINKS } from "../../constants/docLinks";
23
+ import { useServer } from "../ServerProvider";
24
+
25
+ interface AddPackageDialogProps {
26
+ resourceUri: string;
27
+ }
28
+
29
+ export default function AddPackageDialog({
30
+ resourceUri,
31
+ }: AddPackageDialogProps) {
32
+ const [open, setOpen] = useState(false);
33
+ const { apiClients } = useServer();
34
+ const queryClient = useQueryClient();
35
+ const [notificationMessage, setNotificationMessage] = useState("");
36
+
37
+ const { environmentName } = parseResourceUri(resourceUri);
38
+
39
+ const addPackage = useMutationWithApiError({
40
+ async mutationFn(variables: Package) {
41
+ return apiClients.packages.createPackage(environmentName, {
42
+ name: variables.name,
43
+ description: variables.description,
44
+ location: variables.location,
45
+ });
46
+ },
47
+ onSuccess() {
48
+ setOpen(false);
49
+ setNotificationMessage("Package created successfully");
50
+ queryClient.invalidateQueries({
51
+ queryKey: ["packages", environmentName],
52
+ });
53
+ },
54
+ onError(error) {
55
+ setNotificationMessage(
56
+ error instanceof Error
57
+ ? error.message
58
+ : "An unknown error occurred",
59
+ );
60
+ },
61
+ });
62
+
63
+ const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
64
+ event.preventDefault();
65
+ const formData = new FormData(event.currentTarget);
66
+ const name = formData.get("name")?.toString();
67
+ const description = formData.get("description")?.toString();
68
+ const location = formData.get("location")?.toString();
69
+ addPackage.mutate({ name, description, location });
70
+ };
71
+
72
+ return (
73
+ <>
74
+ <Button
75
+ onClick={() => setOpen(true)}
76
+ variant="contained"
77
+ color="primary"
78
+ startIcon={<Add />}
79
+ >
80
+ Add Package
81
+ </Button>
82
+
83
+ <Dialog
84
+ open={open}
85
+ onClose={() => setOpen(false)}
86
+ maxWidth="sm"
87
+ fullWidth
88
+ PaperProps={{ sx: { borderRadius: 2 } }}
89
+ >
90
+ <DialogTitle
91
+ sx={{
92
+ fontSize: "1.25rem",
93
+ fontWeight: 600,
94
+ letterSpacing: "-0.025em",
95
+ pt: 3,
96
+ pb: 1,
97
+ px: 3,
98
+ }}
99
+ >
100
+ Create New Package
101
+ </DialogTitle>
102
+ <DialogContent sx={{ px: 3, pb: 0 }}>
103
+ <Box sx={{ mb: 3 }}>
104
+ <Typography
105
+ variant="body2"
106
+ color="text.secondary"
107
+ sx={{ mb: 1.5 }}
108
+ >
109
+ Create a new Malloy package to start exploring your data.
110
+ </Typography>
111
+ <Typography
112
+ variant="body2"
113
+ color="text.secondary"
114
+ sx={{ mb: 1.5 }}
115
+ >
116
+ The location can be a GitHub/S3/GCP URL containing a
117
+ package (zipped or unzipped), or an absolute path to a
118
+ directory the publisher server has access to.
119
+ </Typography>
120
+ <Typography variant="body2" color="text.secondary">
121
+ Make sure to conform to the{" "}
122
+ <Box
123
+ component="a"
124
+ href={DOC_LINKS.publishing}
125
+ target="_blank"
126
+ rel="noopener noreferrer"
127
+ sx={{
128
+ color: "text.primary",
129
+ textDecoration: "underline",
130
+ }}
131
+ >
132
+ Malloy Package Format
133
+ </Box>
134
+ .
135
+ </Typography>
136
+ </Box>
137
+ <form onSubmit={handleSubmit} id="package-form">
138
+ <Stack spacing={2.5}>
139
+ <TextField
140
+ autoFocus
141
+ required
142
+ id="name"
143
+ name="name"
144
+ label="Package Name"
145
+ type="text"
146
+ fullWidth
147
+ variant="outlined"
148
+ size="small"
149
+ InputLabelProps={{ shrink: true }}
150
+ />
151
+ <TextField
152
+ id="description"
153
+ name="description"
154
+ label="Description"
155
+ multiline
156
+ rows={3}
157
+ fullWidth
158
+ variant="outlined"
159
+ size="small"
160
+ InputLabelProps={{ shrink: true }}
161
+ />
162
+ <TextField
163
+ id="location"
164
+ name="location"
165
+ label="Location"
166
+ type="text"
167
+ placeholder="e.g. s3://my-bucket/my-package.zip"
168
+ fullWidth
169
+ variant="outlined"
170
+ size="small"
171
+ InputLabelProps={{ shrink: true }}
172
+ />
173
+ </Stack>
174
+ </form>
175
+ </DialogContent>
176
+ <DialogActions sx={{ px: 3, pt: 2, pb: 3, gap: 1 }}>
177
+ <Button
178
+ variant="outlined"
179
+ disabled={addPackage.isPending}
180
+ onClick={() => setOpen(false)}
181
+ >
182
+ Cancel
183
+ </Button>
184
+ <Button
185
+ type="submit"
186
+ form="package-form"
187
+ variant="contained"
188
+ loading={addPackage.isPending}
189
+ >
190
+ Save Changes
191
+ </Button>
192
+ </DialogActions>
193
+ </Dialog>
194
+ <Snackbar
195
+ open={notificationMessage !== ""}
196
+ autoHideDuration={6000}
197
+ onClose={() => setNotificationMessage("")}
198
+ message={notificationMessage}
199
+ />
200
+ </>
201
+ );
202
+ }
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import {
2
5
  Box,
3
6
  Divider,
@@ -62,7 +65,7 @@ export default function ConnectionExplorer({
62
65
  connection,
63
66
  }: ConnectionExplorerProps) {
64
67
  const { apiClients } = useServer();
65
- const { projectName: projectName } = parseResourceUri(resourceUri);
68
+ const { environmentName: environmentName } = parseResourceUri(resourceUri);
66
69
  const [selectedTableResource, setSelectedTableResource] = React.useState<
67
70
  string | null
68
71
  >(null);
@@ -76,9 +79,9 @@ export default function ConnectionExplorer({
76
79
  isLoading: schemasLoading,
77
80
  error: schemasErrorObj,
78
81
  } = useQueryWithApiError({
79
- queryKey: ["schemas", projectName, connectionName],
82
+ queryKey: ["schemas", environmentName, connectionName],
80
83
  queryFn: () =>
81
- apiClients.connections.listSchemas(projectName, connectionName),
84
+ apiClients.connections.listSchemas(environmentName, connectionName),
82
85
  });
83
86
 
84
87
  const availableSchemas = schemasData?.data || [];
@@ -119,7 +122,7 @@ export default function ConnectionExplorer({
119
122
  {schemasError && (
120
123
  <ApiErrorDisplay
121
124
  error={schemasErrorObj}
122
- context={`${projectName} > ${connectionName} > Schemas`}
125
+ context={`${environmentName} > ${connectionName} > Schemas`}
123
126
  />
124
127
  )}
125
128
  {!schemasLoading &&
@@ -181,7 +184,7 @@ export default function ConnectionExplorer({
181
184
  <Grid size={{ xs: 12, md: schema ? 6 : 4 }}>
182
185
  {selectedSchema && selectedTableResource && (
183
186
  <SelectedTableDetailPanel
184
- projectName={projectName}
187
+ environmentName={environmentName}
185
188
  connectionName={connectionName}
186
189
  schemaName={selectedSchema}
187
190
  tableResource={selectedTableResource}
@@ -198,12 +201,12 @@ type TableSchemaViewerProps = {
198
201
  };
199
202
 
200
203
  function SelectedTableDetailPanel({
201
- projectName,
204
+ environmentName,
202
205
  connectionName,
203
206
  schemaName,
204
207
  tableResource,
205
208
  }: {
206
- projectName: string;
209
+ environmentName: string;
207
210
  connectionName: string;
208
211
  schemaName: string;
209
212
  tableResource: string;
@@ -217,14 +220,14 @@ function SelectedTableDetailPanel({
217
220
  } = useQueryWithApiError({
218
221
  queryKey: [
219
222
  "connectionTableDetail",
220
- projectName,
223
+ environmentName,
221
224
  connectionName,
222
225
  schemaName,
223
226
  tableResource,
224
227
  ],
225
228
  queryFn: () =>
226
229
  apiClients.connections.getTable(
227
- projectName,
230
+ environmentName,
228
231
  connectionName,
229
232
  schemaName,
230
233
  tableResource,
@@ -242,7 +245,7 @@ function SelectedTableDetailPanel({
242
245
  {tableDetailError && (
243
246
  <ApiErrorDisplay
244
247
  error={tableDetailErrorObj}
245
- context={`${projectName} > ${connectionName} > ${schemaName} > ${tableResource}`}
248
+ context={`${environmentName} > ${connectionName} > ${schemaName} > ${tableResource}`}
246
249
  />
247
250
  )}
248
251
  {!tableDetailError && (
@@ -319,14 +322,14 @@ function TablesInSchema({
319
322
  resourceUri,
320
323
  connection,
321
324
  }: TablesInSchemaProps) {
322
- const { projectName: projectName } = parseResourceUri(resourceUri);
325
+ const { environmentName: environmentName } = parseResourceUri(resourceUri);
323
326
  const { apiClients } = useServer();
324
327
  const [searchTerm, setSearchTerm] = useState("");
325
328
  const { data, isSuccess, isError, error, isLoading } = useQueryWithApiError({
326
- queryKey: ["tablesInSchema", projectName, connectionName, schemaName],
329
+ queryKey: ["tablesInSchema", environmentName, connectionName, schemaName],
327
330
  queryFn: () =>
328
331
  apiClients.connections.listTables(
329
- projectName,
332
+ environmentName,
330
333
  connectionName,
331
334
  schemaName,
332
335
  ),
@@ -376,7 +379,7 @@ function TablesInSchema({
376
379
  {isError && (
377
380
  <ApiErrorDisplay
378
381
  error={error}
379
- context={`${projectName} > ${connectionName} > ${schemaName}`}
382
+ context={`${environmentName} > ${connectionName} > ${schemaName}`}
380
383
  />
381
384
  )}
382
385
  {isSuccess && filteredTables.length === 0 && (