@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,87 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import {
5
+ Box,
6
+ Stack,
7
+ Table,
8
+ TableBody,
9
+ TableCell,
10
+ TableHead,
11
+ TableRow,
12
+ Typography,
13
+ } from "@mui/material";
14
+ import { ManifestEntry } from "../../client";
15
+ import { MONO_FONT_FAMILY } from "../styles";
16
+ import SectionLabel from "./SectionLabel";
17
+ import { formatTimestamp } from "./utils";
18
+
19
+ type ManifestViewProps = {
20
+ entries: { [sourceEntityId: string]: ManifestEntry } | undefined;
21
+ builtAt?: string;
22
+ };
23
+
24
+ /**
25
+ * Read-only view of a materialization's build manifest: the physical tables
26
+ * produced from the build plan, carried on the materialization resource.
27
+ */
28
+ export default function ManifestView({ entries, builtAt }: ManifestViewProps) {
29
+ const rows = Object.entries(entries ?? {});
30
+
31
+ return (
32
+ <Box>
33
+ <Stack
34
+ direction="row"
35
+ alignItems="baseline"
36
+ justifyContent="space-between"
37
+ >
38
+ <SectionLabel>Build manifest</SectionLabel>
39
+ {builtAt && (
40
+ <Typography variant="caption" color="text.secondary">
41
+ Built {formatTimestamp(builtAt)}
42
+ </Typography>
43
+ )}
44
+ </Stack>
45
+ {rows.length === 0 ? (
46
+ <Typography
47
+ variant="body2"
48
+ color="text.secondary"
49
+ sx={{ fontStyle: "italic" }}
50
+ >
51
+ No materialized tables yet.
52
+ </Typography>
53
+ ) : (
54
+ <Table size="small">
55
+ <TableHead>
56
+ <TableRow>
57
+ <TableCell>Source</TableCell>
58
+ <TableCell>Table name</TableCell>
59
+ <TableCell>Connection</TableCell>
60
+ <TableCell>Realization</TableCell>
61
+ <TableCell align="right">Rows</TableCell>
62
+ </TableRow>
63
+ </TableHead>
64
+ <TableBody>
65
+ {rows.map(([sourceEntityId, entry]) => (
66
+ <TableRow key={sourceEntityId}>
67
+ <TableCell sx={{ fontFamily: MONO_FONT_FAMILY }}>
68
+ {entry.sourceName ?? sourceEntityId}
69
+ </TableCell>
70
+ <TableCell sx={{ fontFamily: MONO_FONT_FAMILY }}>
71
+ {entry.physicalTableName ?? "-"}
72
+ </TableCell>
73
+ <TableCell sx={{ fontFamily: MONO_FONT_FAMILY }}>
74
+ {entry.connectionName ?? "-"}
75
+ </TableCell>
76
+ <TableCell>{entry.realization ?? "-"}</TableCell>
77
+ <TableCell align="right">
78
+ {entry.rowCount ?? "-"}
79
+ </TableCell>
80
+ </TableRow>
81
+ ))}
82
+ </TableBody>
83
+ </Table>
84
+ )}
85
+ </Box>
86
+ );
87
+ }
@@ -0,0 +1,259 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import CloseIcon from "@mui/icons-material/Close";
5
+ import {
6
+ Box,
7
+ Chip,
8
+ Dialog,
9
+ DialogContent,
10
+ DialogTitle,
11
+ IconButton,
12
+ Stack,
13
+ Table,
14
+ TableBody,
15
+ TableCell,
16
+ TableHead,
17
+ TableRow,
18
+ Typography,
19
+ } from "@mui/material";
20
+ import { BuildPlan, Materialization } from "../../client";
21
+ import { MONO_FONT_FAMILY } from "../styles";
22
+ import ManifestView from "./ManifestView";
23
+ import SectionLabel from "./SectionLabel";
24
+ import TriggerChip from "./TriggerChip";
25
+ import {
26
+ formatDuration,
27
+ formatTimestamp,
28
+ isActiveStatus,
29
+ parseMetadata,
30
+ statusColor,
31
+ statusLabel,
32
+ } from "./utils";
33
+
34
+ type MaterializationDetailDialogProps = {
35
+ materialization: Materialization | null;
36
+ // The compiled package's current build plan (Package.buildPlan), shown for
37
+ // context. It is a property of the package version, not the historical run.
38
+ // Note it is null both in the environment-scoped view and for a package with
39
+ // no persist sources, so it cannot itself gate the section — see
40
+ // `showBuildPlan`.
41
+ buildPlan: BuildPlan | null;
42
+ // Whether to render the Build plan section. The package view shows it (with a
43
+ // "no persist sources" empty state when the plan is empty); the
44
+ // environment-scoped view, which spans packages and has no single plan, omits
45
+ // it entirely.
46
+ showBuildPlan?: boolean;
47
+ onClose: () => void;
48
+ };
49
+
50
+ export default function MaterializationDetailDialog({
51
+ materialization,
52
+ buildPlan,
53
+ showBuildPlan = true,
54
+ onClose,
55
+ }: MaterializationDetailDialogProps) {
56
+ const meta = materialization ? parseMetadata(materialization) : {};
57
+ const planSources = Object.values(buildPlan?.sources ?? {});
58
+
59
+ return (
60
+ <Dialog
61
+ open={materialization !== null}
62
+ onClose={onClose}
63
+ maxWidth="md"
64
+ fullWidth
65
+ aria-labelledby="materialization-detail-title"
66
+ >
67
+ {materialization && (
68
+ <>
69
+ <DialogTitle
70
+ sx={{ pr: 6, pb: 1.5 }}
71
+ id="materialization-detail-title"
72
+ >
73
+ <Stack
74
+ direction="row"
75
+ alignItems="center"
76
+ spacing={1}
77
+ sx={{ mb: 0.75 }}
78
+ >
79
+ <Chip
80
+ size="small"
81
+ label={statusLabel(materialization.status)}
82
+ color={statusColor(materialization.status)}
83
+ variant={
84
+ isActiveStatus(materialization.status)
85
+ ? "filled"
86
+ : "outlined"
87
+ }
88
+ />
89
+ <TriggerChip meta={meta} />
90
+ </Stack>
91
+ <Typography variant="subtitle1" sx={{ fontWeight: 600 }}>
92
+ {materialization.packageName ?? "Materialization"}
93
+ </Typography>
94
+ <Typography
95
+ variant="caption"
96
+ color="text.secondary"
97
+ sx={{
98
+ fontFamily: MONO_FONT_FAMILY,
99
+ wordBreak: "break-all",
100
+ }}
101
+ >
102
+ {materialization.id}
103
+ </Typography>
104
+ <IconButton
105
+ aria-label="close"
106
+ onClick={onClose}
107
+ sx={{ position: "absolute", right: 8, top: 8 }}
108
+ >
109
+ <CloseIcon fontSize="small" />
110
+ </IconButton>
111
+ </DialogTitle>
112
+ <DialogContent dividers>
113
+ <Box
114
+ sx={{
115
+ bgcolor: "action.hover",
116
+ borderRadius: 2,
117
+ p: 2,
118
+ mb: 3,
119
+ display: "grid",
120
+ gridTemplateColumns:
121
+ "repeat(auto-fit, minmax(140px, 1fr))",
122
+ gap: 2,
123
+ }}
124
+ >
125
+ <DetailField
126
+ label="Started"
127
+ value={formatTimestamp(
128
+ materialization.startedAt ??
129
+ materialization.createdAt,
130
+ )}
131
+ />
132
+ <DetailField
133
+ label="Completed"
134
+ value={formatTimestamp(materialization.completedAt)}
135
+ />
136
+ <DetailField
137
+ label="Duration"
138
+ value={formatDuration(
139
+ materialization.startedAt,
140
+ materialization.completedAt,
141
+ )}
142
+ />
143
+ <DetailField
144
+ label="Sources"
145
+ value={`${meta.sourcesBuilt ?? 0} built · ${meta.sourcesReused ?? 0} reused`}
146
+ />
147
+ <DetailField
148
+ label="Force refresh"
149
+ value={meta.forceRefresh ? "Yes" : "No"}
150
+ />
151
+ </Box>
152
+
153
+ {materialization.error && (
154
+ <Box
155
+ sx={{
156
+ borderRadius: 2,
157
+ p: 2,
158
+ mb: 3,
159
+ border: "1px solid",
160
+ borderColor: "error.main",
161
+ }}
162
+ >
163
+ <SectionLabel>
164
+ <Box component="span" sx={{ color: "error.main" }}>
165
+ Error
166
+ </Box>
167
+ </SectionLabel>
168
+ <Typography
169
+ variant="body2"
170
+ sx={{
171
+ fontFamily: MONO_FONT_FAMILY,
172
+ whiteSpace: "pre-wrap",
173
+ }}
174
+ >
175
+ {materialization.error}
176
+ </Typography>
177
+ </Box>
178
+ )}
179
+
180
+ {showBuildPlan && (
181
+ <Box sx={{ mb: 3 }}>
182
+ <SectionLabel>Build plan</SectionLabel>
183
+ {planSources.length === 0 ? (
184
+ <Typography
185
+ variant="body2"
186
+ color="text.secondary"
187
+ sx={{ fontStyle: "italic" }}
188
+ >
189
+ This package has no persist sources.
190
+ </Typography>
191
+ ) : (
192
+ <Table size="small">
193
+ <TableHead>
194
+ <TableRow>
195
+ <TableCell>Source</TableCell>
196
+ <TableCell>Connection</TableCell>
197
+ <TableCell>Dialect</TableCell>
198
+ <TableCell align="right">Columns</TableCell>
199
+ <TableCell>Source Entity ID</TableCell>
200
+ </TableRow>
201
+ </TableHead>
202
+ <TableBody>
203
+ {planSources.map((source) => (
204
+ <TableRow key={source.sourceID}>
205
+ <TableCell
206
+ sx={{ fontFamily: MONO_FONT_FAMILY }}
207
+ >
208
+ {source.name}
209
+ </TableCell>
210
+ <TableCell
211
+ sx={{ fontFamily: MONO_FONT_FAMILY }}
212
+ >
213
+ {source.connectionName}
214
+ </TableCell>
215
+ <TableCell>
216
+ {source.dialect ?? "-"}
217
+ </TableCell>
218
+ <TableCell align="right">
219
+ {source.columns?.length ?? 0}
220
+ </TableCell>
221
+ <TableCell
222
+ sx={{
223
+ fontFamily: MONO_FONT_FAMILY,
224
+ fontSize: "0.75rem",
225
+ wordBreak: "break-all",
226
+ maxWidth: 220,
227
+ }}
228
+ >
229
+ {source.sourceEntityId}
230
+ </TableCell>
231
+ </TableRow>
232
+ ))}
233
+ </TableBody>
234
+ </Table>
235
+ )}
236
+ </Box>
237
+ )}
238
+
239
+ <ManifestView
240
+ entries={materialization.manifest?.entries}
241
+ builtAt={materialization.manifest?.builtAt}
242
+ />
243
+ </DialogContent>
244
+ </>
245
+ )}
246
+ </Dialog>
247
+ );
248
+ }
249
+
250
+ function DetailField({ label, value }: { label: string; value: string }) {
251
+ return (
252
+ <Box>
253
+ <Typography variant="caption" color="text.secondary" display="block">
254
+ {label}
255
+ </Typography>
256
+ <Typography variant="body2">{value}</Typography>
257
+ </Box>
258
+ );
259
+ }
@@ -0,0 +1,256 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { MoreVert } from "@mui/icons-material";
5
+ import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
6
+ import StopIcon from "@mui/icons-material/Stop";
7
+ import {
8
+ Box,
9
+ Chip,
10
+ IconButton,
11
+ Link,
12
+ ListItemIcon,
13
+ ListItemText,
14
+ Menu,
15
+ MenuItem,
16
+ Table,
17
+ TableBody,
18
+ TableCell,
19
+ TableHead,
20
+ TableRow,
21
+ Tooltip,
22
+ Typography,
23
+ } from "@mui/material";
24
+ import { useState } from "react";
25
+ import { Materialization } from "../../client";
26
+ import DeleteMaterializationDialog from "./DeleteMaterializationDialog";
27
+ import TriggerChip from "./TriggerChip";
28
+ import {
29
+ formatDuration,
30
+ formatRelativeTime,
31
+ isActiveStatus,
32
+ isTerminalStatus,
33
+ parseMetadata,
34
+ statusColor,
35
+ statusLabel,
36
+ } from "./utils";
37
+
38
+ type MaterializationRunsListProps = {
39
+ materializations: Materialization[];
40
+ mutable: boolean;
41
+ isMutating: boolean;
42
+ /** Show a Package column — for the environment-scoped view spanning packages. */
43
+ showPackage?: boolean;
44
+ /** Navigate to a package (used by the Package column links). */
45
+ onClickPackage?: (packageName: string) => void;
46
+ onStop: (materialization: Materialization) => void;
47
+ onDelete: (materialization: Materialization, dropTables: boolean) => void;
48
+ onViewDetails: (materialization: Materialization) => void;
49
+ };
50
+
51
+ export default function MaterializationRunsList({
52
+ materializations,
53
+ mutable,
54
+ isMutating,
55
+ showPackage = false,
56
+ onClickPackage,
57
+ onStop,
58
+ onDelete,
59
+ onViewDetails,
60
+ }: MaterializationRunsListProps) {
61
+ if (materializations.length === 0) {
62
+ return (
63
+ <Typography
64
+ variant="body2"
65
+ color="text.secondary"
66
+ sx={{ py: 1, fontStyle: "italic" }}
67
+ >
68
+ No materializations yet.
69
+ </Typography>
70
+ );
71
+ }
72
+
73
+ return (
74
+ <Table size="small">
75
+ <TableHead>
76
+ <TableRow>
77
+ {showPackage && <TableCell>Package</TableCell>}
78
+ <TableCell>Status</TableCell>
79
+ <TableCell>Trigger</TableCell>
80
+ <TableCell>Started</TableCell>
81
+ <TableCell>Duration</TableCell>
82
+ <TableCell>Sources</TableCell>
83
+ <TableCell align="right">Actions</TableCell>
84
+ </TableRow>
85
+ </TableHead>
86
+ <TableBody>
87
+ {materializations.map((materialization) => (
88
+ <MaterializationRow
89
+ key={materialization.id}
90
+ materialization={materialization}
91
+ mutable={mutable}
92
+ isMutating={isMutating}
93
+ showPackage={showPackage}
94
+ onClickPackage={onClickPackage}
95
+ onStop={onStop}
96
+ onDelete={onDelete}
97
+ onViewDetails={onViewDetails}
98
+ />
99
+ ))}
100
+ </TableBody>
101
+ </Table>
102
+ );
103
+ }
104
+
105
+ function MaterializationRow({
106
+ materialization,
107
+ mutable,
108
+ isMutating,
109
+ showPackage,
110
+ onClickPackage,
111
+ onStop,
112
+ onDelete,
113
+ onViewDetails,
114
+ }: {
115
+ materialization: Materialization;
116
+ mutable: boolean;
117
+ isMutating: boolean;
118
+ showPackage?: boolean;
119
+ onClickPackage?: (packageName: string) => void;
120
+ onStop: (materialization: Materialization) => void;
121
+ onDelete: (materialization: Materialization, dropTables: boolean) => void;
122
+ onViewDetails: (materialization: Materialization) => void;
123
+ }) {
124
+ const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
125
+ const menuOpen = Boolean(menuAnchorEl);
126
+ const handleMenuClose = () => setMenuAnchorEl(null);
127
+
128
+ const meta = parseMetadata(materialization);
129
+ const sourcesLabel =
130
+ meta.sourcesBuilt !== undefined || meta.sourcesReused !== undefined
131
+ ? `${meta.sourcesBuilt ?? 0} built, ${meta.sourcesReused ?? 0} reused`
132
+ : "-";
133
+ const active = isActiveStatus(materialization.status);
134
+ const terminal = isTerminalStatus(materialization.status);
135
+ const error = materialization.error ?? undefined;
136
+ const hasActions = mutable && (active || terminal);
137
+
138
+ return (
139
+ <TableRow
140
+ hover
141
+ sx={{
142
+ cursor: "pointer",
143
+ "&:focus-visible": {
144
+ outline: "2px solid",
145
+ outlineColor: "primary.main",
146
+ outlineOffset: "-2px",
147
+ },
148
+ }}
149
+ onClick={() => onViewDetails(materialization)}
150
+ onKeyDown={(event) => {
151
+ if (event.key === "Enter" || event.key === " ") {
152
+ event.preventDefault();
153
+ onViewDetails(materialization);
154
+ }
155
+ }}
156
+ role="button"
157
+ tabIndex={0}
158
+ aria-label={`View materialization ${materialization.id ?? ""} details`.trim()}
159
+ >
160
+ {showPackage && (
161
+ <TableCell onClick={(event) => event.stopPropagation()}>
162
+ {onClickPackage ? (
163
+ <Link
164
+ component="button"
165
+ underline="hover"
166
+ onClick={() =>
167
+ onClickPackage(materialization.packageName ?? "")
168
+ }
169
+ sx={{ fontWeight: 500 }}
170
+ >
171
+ {materialization.packageName}
172
+ </Link>
173
+ ) : (
174
+ materialization.packageName
175
+ )}
176
+ </TableCell>
177
+ )}
178
+ <TableCell>
179
+ <Box sx={{ display: "flex", alignItems: "center", gap: 0.5 }}>
180
+ <Chip
181
+ size="small"
182
+ label={statusLabel(materialization.status)}
183
+ color={statusColor(materialization.status)}
184
+ variant={active ? "filled" : "outlined"}
185
+ />
186
+ {error && (
187
+ <Tooltip title={error}>
188
+ <InfoOutlinedIcon fontSize="small" color="error" />
189
+ </Tooltip>
190
+ )}
191
+ </Box>
192
+ </TableCell>
193
+ <TableCell>
194
+ <TriggerChip meta={meta} />
195
+ </TableCell>
196
+ <TableCell>
197
+ {formatRelativeTime(
198
+ materialization.startedAt ?? materialization.createdAt,
199
+ )}
200
+ </TableCell>
201
+ <TableCell>
202
+ {formatDuration(
203
+ materialization.startedAt,
204
+ materialization.completedAt,
205
+ )}
206
+ </TableCell>
207
+ <TableCell>{sourcesLabel}</TableCell>
208
+ <TableCell align="right" onClick={(event) => event.stopPropagation()}>
209
+ {hasActions && (
210
+ <>
211
+ <IconButton
212
+ size="small"
213
+ aria-label={`Materialization actions for ${materialization.id ?? ""}`.trim()}
214
+ onClick={(event) => setMenuAnchorEl(event.currentTarget)}
215
+ >
216
+ <MoreVert fontSize="small" />
217
+ </IconButton>
218
+ <Menu
219
+ anchorEl={menuAnchorEl}
220
+ open={menuOpen}
221
+ onClose={handleMenuClose}
222
+ anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
223
+ transformOrigin={{ vertical: "top", horizontal: "right" }}
224
+ >
225
+ {mutable && active && (
226
+ <MenuItem
227
+ aria-label={`Stop materialization ${materialization.id ?? ""}`.trim()}
228
+ disabled={isMutating}
229
+ onClick={() => {
230
+ handleMenuClose();
231
+ onStop(materialization);
232
+ }}
233
+ >
234
+ <ListItemIcon>
235
+ <StopIcon fontSize="small" />
236
+ </ListItemIcon>
237
+ <ListItemText>Stop</ListItemText>
238
+ </MenuItem>
239
+ )}
240
+ {mutable && terminal && (
241
+ <DeleteMaterializationDialog
242
+ materialization={materialization}
243
+ isMutating={isMutating}
244
+ onCloseDialog={handleMenuClose}
245
+ onDelete={(dropTables) =>
246
+ onDelete(materialization, dropTables)
247
+ }
248
+ />
249
+ )}
250
+ </Menu>
251
+ </>
252
+ )}
253
+ </TableCell>
254
+ </TableRow>
255
+ );
256
+ }