@malloy-publisher/sdk 0.0.382-dev → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) 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-Cn_LhKda.cjs.js +1 -0
  5. package/dist/ServerProvider-sfabtriY.es.js +4076 -0
  6. package/dist/client/api.d.ts +3773 -1515
  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 +86 -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 +62 -0
  14. package/dist/components/Dashboard/DashboardTile.d.ts +57 -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-CqRKhtoy.cjs.js} +1 -1
  66. package/dist/{core-CjeTkq8O.es.js → core-DyU47reh.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-DRDu9kIV.es.js → index-CAkFE4Ol.es.js} +41278 -28504
  78. package/dist/index-DD4b_bt0.cjs.js +356 -0
  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 +41 -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 +132 -25
  104. package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
  105. package/src/components/Connections/EditConnectionDialog.tsx +167 -37
  106. package/src/components/Connections/common.ts +94 -3
  107. package/src/components/DOMElement/DOMElement.tsx +3 -0
  108. package/src/components/DOMElement/index.ts +3 -0
  109. package/src/components/Dashboard/Dashboard.spec.tsx +216 -0
  110. package/src/components/Dashboard/Dashboard.tsx +458 -0
  111. package/src/components/Dashboard/DashboardTile.spec.tsx +81 -0
  112. package/src/components/Dashboard/DashboardTile.tsx +199 -0
  113. package/src/components/Dashboard/index.ts +5 -0
  114. package/src/components/Dashboard/tileGridColumn.spec.ts +35 -0
  115. package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
  116. package/src/components/DataAppViewer/index.ts +4 -0
  117. package/src/components/{Project → Environment}/About.tsx +11 -4
  118. package/src/components/Environment/AddPackageDialog.tsx +202 -0
  119. package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
  120. package/src/components/Environment/Connections.tsx +391 -0
  121. package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
  122. package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
  123. package/src/components/Environment/Environment.tsx +89 -0
  124. package/src/components/Environment/Packages.tsx +206 -0
  125. package/src/components/Environment/index.ts +5 -0
  126. package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
  127. package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
  128. package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
  129. package/src/components/Home/Home.tsx +386 -408
  130. package/src/components/Home/index.ts +3 -0
  131. package/src/components/Loading.tsx +3 -0
  132. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
  133. package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
  134. package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
  135. package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
  136. package/src/components/Materializations/ManifestView.tsx +87 -0
  137. package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
  138. package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
  139. package/src/components/Materializations/Materializations.tsx +355 -0
  140. package/src/components/Materializations/ScheduleCard.tsx +231 -0
  141. package/src/components/Materializations/SectionLabel.tsx +30 -0
  142. package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
  143. package/src/components/Materializations/TriggerChip.tsx +44 -0
  144. package/src/components/Materializations/cron.ts +124 -0
  145. package/src/components/Materializations/index.ts +5 -0
  146. package/src/components/Materializations/utils.ts +145 -0
  147. package/src/components/Model/Model.tsx +44 -2
  148. package/src/components/Model/ModelCell.tsx +14 -5
  149. package/src/components/Model/ModelExplorer.tsx +3 -0
  150. package/src/components/Model/ModelExplorerDialog.tsx +4 -1
  151. package/src/components/Model/SourcesExplorer.tsx +9 -6
  152. package/src/components/Model/index.ts +3 -0
  153. package/src/components/Model/useModelData.ts +6 -3
  154. package/src/components/Notebook/Notebook.spec.tsx +88 -0
  155. package/src/components/Notebook/Notebook.tsx +476 -339
  156. package/src/components/Notebook/NotebookCell.tsx +264 -25
  157. package/src/components/Notebook/index.ts +3 -0
  158. package/src/components/Notebook/runPlan.spec.ts +155 -0
  159. package/src/components/Notebook/runPlan.ts +67 -0
  160. package/src/components/Notebook/types.ts +14 -0
  161. package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
  162. package/src/components/Package/ContentTypeIcon.tsx +177 -0
  163. package/src/components/Package/FileTreeView.tsx +3 -0
  164. package/src/components/Package/Models.tsx +7 -4
  165. package/src/components/Package/Package.spec.tsx +113 -0
  166. package/src/components/Package/Package.tsx +692 -59
  167. package/src/components/Package/index.ts +3 -0
  168. package/src/components/QueryResult/QueryResult.tsx +17 -8
  169. package/src/components/QueryResult/index.ts +3 -0
  170. package/src/components/RenderedResult/RenderedResult.tsx +725 -67
  171. package/src/components/RenderedResult/ResultContainer.tsx +71 -2
  172. package/src/components/RenderedResult/index.ts +3 -0
  173. package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
  174. package/src/components/RenderedResult/renderLogs.ts +43 -0
  175. package/src/components/ResultsDialog.tsx +13 -1
  176. package/src/components/ServerProvider.tsx +175 -51
  177. package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
  178. package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
  179. package/src/components/Workbook/ModelPicker.tsx +7 -4
  180. package/src/components/Workbook/MutableCell.tsx +10 -5
  181. package/src/components/Workbook/Workbook.tsx +8 -5
  182. package/src/components/Workbook/WorkbookList.tsx +3 -0
  183. package/src/components/Workbook/WorkbookManager.ts +3 -0
  184. package/src/components/Workbook/WorkbookStorage.ts +3 -0
  185. package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
  186. package/src/components/Workbook/index.ts +3 -0
  187. package/src/components/click_helper.ts +17 -1
  188. package/src/components/drill/index.ts +28 -0
  189. package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
  190. package/src/components/drill/markDrillableCells.spec.ts +109 -0
  191. package/src/components/drill/markDrillableCells.ts +314 -0
  192. package/src/components/drill/resolveDrill.spec.ts +449 -0
  193. package/src/components/drill/resolveDrill.ts +375 -0
  194. package/src/components/drill/useDrill.tsx +203 -0
  195. package/src/components/filter/DimensionFilter.tsx +3 -0
  196. package/src/components/filter/index.ts +3 -0
  197. package/src/components/filter/utils.ts +16 -5
  198. package/src/components/given/GivenInput.spec.tsx +689 -0
  199. package/src/components/given/GivenInput.tsx +801 -0
  200. package/src/components/given/GivensPanel.spec.tsx +175 -0
  201. package/src/components/given/GivensPanel.tsx +195 -0
  202. package/src/components/given/filterValue.spec.ts +364 -0
  203. package/src/components/given/filterValue.ts +207 -0
  204. package/src/components/given/index.ts +9 -0
  205. package/src/components/given/paramCodec.spec.ts +857 -0
  206. package/src/components/given/paramCodec.ts +483 -0
  207. package/src/components/given/utils.spec.ts +60 -0
  208. package/src/components/given/utils.ts +79 -0
  209. package/src/components/highlighter.ts +22 -5
  210. package/src/components/index.ts +10 -2
  211. package/src/components/styles.ts +82 -33
  212. package/src/constants/docLinks.spec.ts +54 -0
  213. package/src/constants/docLinks.ts +46 -0
  214. package/src/hooks/givenValue.ts +13 -0
  215. package/src/hooks/index.ts +13 -0
  216. package/src/hooks/useDimensionFilters.ts +4 -7
  217. package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
  218. package/src/hooks/useDimensionFiltersQuery.ts +10 -13
  219. package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
  220. package/src/hooks/useGivensState.spec.ts +449 -0
  221. package/src/hooks/useGivensState.ts +340 -0
  222. package/src/hooks/useModelGivens.ts +29 -0
  223. package/src/hooks/useQueryWithApiError.ts +3 -0
  224. package/src/hooks/useRawQueryData.ts +6 -3
  225. package/src/hooks/useSuggestOptions.dom.spec.ts +91 -0
  226. package/src/hooks/useSuggestOptions.spec.ts +112 -0
  227. package/src/hooks/useSuggestOptions.ts +268 -0
  228. package/src/index.ts +10 -1
  229. package/src/react-app-env.d.ts +3 -0
  230. package/src/theme/ThemeContext.tsx +86 -0
  231. package/src/theme/buildMalloyExplicitTheme.ts +61 -0
  232. package/src/theme/buildTableCssVars.spec.ts +86 -0
  233. package/src/theme/buildTableCssVars.ts +98 -0
  234. package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
  235. package/src/theme/buildVegaThemeOverride.ts +47 -0
  236. package/src/theme/defaults.ts +78 -0
  237. package/src/theme/index.ts +11 -0
  238. package/src/theme/keys.ts +32 -0
  239. package/src/theme/readChartAnnotations.spec.ts +58 -0
  240. package/src/theme/readChartAnnotations.ts +69 -0
  241. package/src/theme/resolveTheme.spec.ts +160 -0
  242. package/src/theme/resolveTheme.ts +121 -0
  243. package/src/theme/types.ts +79 -0
  244. package/src/utils/dataAppEmbed.spec.ts +63 -0
  245. package/src/utils/dataAppEmbed.ts +84 -0
  246. package/src/utils/formatting.spec.ts +25 -21
  247. package/src/utils/formatting.ts +11 -7
  248. package/src/utils/malloyString.spec.ts +24 -0
  249. package/src/utils/malloyString.ts +12 -0
  250. package/src/utils/parsing.spec.ts +26 -19
  251. package/src/utils/parsing.ts +11 -6
  252. package/src/utils/queryClient.ts +17 -0
  253. package/test/README.md +185 -0
  254. package/test/serverProvider.tsx +72 -0
  255. package/test/setup.ts +29 -0
  256. package/tsconfig.json +12 -1
  257. package/tsconfig.spec.json +22 -0
  258. package/vite.config.ts +3 -0
  259. package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
  260. package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
  261. package/dist/components/Home/AddProjectDialog.d.ts +0 -1
  262. package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
  263. package/dist/components/Home/EditProjectDialog.d.ts +0 -7
  264. package/dist/components/Package/Config.d.ts +0 -5
  265. package/dist/components/Package/Databases.d.ts +0 -5
  266. package/dist/components/Package/Notebooks.d.ts +0 -6
  267. package/dist/components/Project/Project.d.ts +0 -6
  268. package/dist/components/Project/index.d.ts +0 -2
  269. package/dist/index-BOLBP6_i.cjs.js +0 -233
  270. package/src/components/Package/Config.tsx +0 -97
  271. package/src/components/Package/Connections.tsx +0 -373
  272. package/src/components/Package/Databases.tsx +0 -228
  273. package/src/components/Package/Notebooks.tsx +0 -77
  274. package/src/components/Project/AddPackageDialog.tsx +0 -159
  275. package/src/components/Project/Packages.tsx +0 -191
  276. package/src/components/Project/Project.tsx +0 -52
  277. package/src/components/Project/index.ts +0 -2
  278. /package/dist/components/{Project → Environment}/About.d.ts +0 -0
  279. /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
  280. /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
  281. /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
  282. /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
  283. /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
  284. /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
@@ -0,0 +1,162 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import ScheduleIcon from "@mui/icons-material/Schedule";
5
+ import {
6
+ Alert,
7
+ Box,
8
+ Button,
9
+ Dialog,
10
+ DialogActions,
11
+ DialogContent,
12
+ DialogContentText,
13
+ DialogTitle,
14
+ TextField,
15
+ Tooltip,
16
+ Typography,
17
+ } from "@mui/material";
18
+ import { useState } from "react";
19
+ import { MONO_FONT_FAMILY } from "../styles";
20
+ import { describeCron, formatNextRun } from "./cron";
21
+
22
+ type SetScheduleDialogProps = {
23
+ /** The current cron, or null when no schedule is set. */
24
+ currentSchedule: string | null;
25
+ isSubmitting: boolean;
26
+ disabled?: boolean;
27
+ disabledReason?: string;
28
+ /** Persist a new cron, or null to clear the schedule. */
29
+ onSubmit: (schedule: string | null) => Promise<unknown>;
30
+ };
31
+
32
+ const DEFAULT_CRON = "0 6 * * *";
33
+
34
+ export default function SetScheduleDialog({
35
+ currentSchedule,
36
+ isSubmitting,
37
+ disabled,
38
+ disabledReason,
39
+ onSubmit,
40
+ }: SetScheduleDialogProps) {
41
+ const [open, setOpen] = useState(false);
42
+ const [expr, setExpr] = useState(currentSchedule ?? DEFAULT_CRON);
43
+
44
+ const handleOpen = () => {
45
+ setExpr(currentSchedule ?? DEFAULT_CRON);
46
+ setOpen(true);
47
+ };
48
+ const handleClose = () => setOpen(false);
49
+
50
+ const info = describeCron(expr);
51
+
52
+ const submit = async (schedule: string | null) => {
53
+ try {
54
+ await onSubmit(schedule);
55
+ setOpen(false);
56
+ } catch {
57
+ // The caller surfaces the error via its Snackbar; keep the dialog
58
+ // open so the user can correct the cron and retry.
59
+ }
60
+ };
61
+
62
+ const button = (
63
+ <span>
64
+ <Button
65
+ variant="outlined"
66
+ size="small"
67
+ startIcon={<ScheduleIcon />}
68
+ onClick={handleOpen}
69
+ disabled={disabled}
70
+ aria-label={currentSchedule ? "Edit schedule" : "Set schedule"}
71
+ >
72
+ {currentSchedule ? "Edit schedule" : "Set schedule"}
73
+ </Button>
74
+ </span>
75
+ );
76
+
77
+ return (
78
+ <>
79
+ {disabled && disabledReason ? (
80
+ <Tooltip title={disabledReason}>{button}</Tooltip>
81
+ ) : (
82
+ button
83
+ )}
84
+
85
+ <Dialog
86
+ open={open}
87
+ onClose={handleClose}
88
+ maxWidth="xs"
89
+ fullWidth
90
+ aria-labelledby="set-schedule-title"
91
+ >
92
+ <DialogTitle id="set-schedule-title">
93
+ {currentSchedule ? "Edit schedule" : "Set schedule"}
94
+ </DialogTitle>
95
+ <DialogContent>
96
+ <DialogContentText sx={{ mb: 2 }}>
97
+ The publisher rebuilds the materializations in this package on
98
+ this cadence. Enter a 5-field UNIX cron, evaluated in UTC. In
99
+ a hosted deployment, the change takes effect on your next
100
+ publish.
101
+ </DialogContentText>
102
+ <TextField
103
+ autoFocus
104
+ fullWidth
105
+ label="Cron expression"
106
+ value={expr}
107
+ onChange={(event) => setExpr(event.target.value)}
108
+ error={expr.trim() !== "" && !info.valid}
109
+ slotProps={{
110
+ htmlInput: { style: { fontFamily: MONO_FONT_FAMILY } },
111
+ }}
112
+ />
113
+ <Box sx={{ mt: 1.5, minHeight: 48 }}>
114
+ {info.valid ? (
115
+ <>
116
+ <Typography variant="body2">
117
+ {info.description}
118
+ </Typography>
119
+ <Typography variant="body2" color="text.secondary">
120
+ Next run: {formatNextRun(info.nextRun)}
121
+ </Typography>
122
+ </>
123
+ ) : (
124
+ <Typography variant="body2" color="error">
125
+ {info.error}
126
+ </Typography>
127
+ )}
128
+ </Box>
129
+ <Alert severity="info" sx={{ mt: 2 }}>
130
+ A schedule runs only on version-scoped packages, so saving one
131
+ sets <code>scope: version</code> for this package.
132
+ </Alert>
133
+ </DialogContent>
134
+ <DialogActions sx={{ justifyContent: "space-between", px: 3 }}>
135
+ <Box>
136
+ {currentSchedule && (
137
+ <Button
138
+ color="error"
139
+ loading={isSubmitting}
140
+ onClick={() => submit(null)}
141
+ >
142
+ Clear schedule
143
+ </Button>
144
+ )}
145
+ </Box>
146
+ <Box>
147
+ <Button onClick={handleClose}>Cancel</Button>
148
+ <Button
149
+ variant="contained"
150
+ loading={isSubmitting}
151
+ disabled={!info.valid}
152
+ onClick={() => submit(expr.trim())}
153
+ sx={{ ml: 1 }}
154
+ >
155
+ Save
156
+ </Button>
157
+ </Box>
158
+ </DialogActions>
159
+ </Dialog>
160
+ </>
161
+ );
162
+ }
@@ -0,0 +1,44 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import ScheduleIcon from "@mui/icons-material/Schedule";
5
+ import TouchAppIcon from "@mui/icons-material/TouchApp";
6
+ import { Chip, Tooltip } from "@mui/material";
7
+ import { MaterializationMetadata, triggerLabel } from "./utils";
8
+
9
+ /**
10
+ * Chip showing how a run was initiated — Scheduled (the standalone scheduler
11
+ * fired the package's cron) vs Manual (an API/UI create) — with a tooltip. One
12
+ * source of truth for the color/icon/label so the runs list and the detail
13
+ * dialog can never drift.
14
+ */
15
+ export default function TriggerChip({
16
+ meta,
17
+ }: {
18
+ meta: MaterializationMetadata;
19
+ }) {
20
+ const scheduled = meta.trigger === "SCHEDULER";
21
+ return (
22
+ <Tooltip
23
+ title={
24
+ scheduled
25
+ ? "Fired by the materialization schedule"
26
+ : "Triggered manually"
27
+ }
28
+ >
29
+ <Chip
30
+ size="small"
31
+ variant="outlined"
32
+ color={scheduled ? "info" : "default"}
33
+ icon={
34
+ scheduled ? (
35
+ <ScheduleIcon fontSize="small" />
36
+ ) : (
37
+ <TouchAppIcon fontSize="small" />
38
+ )
39
+ }
40
+ label={triggerLabel(meta)}
41
+ />
42
+ </Tooltip>
43
+ );
44
+ }
@@ -0,0 +1,124 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { CronExpressionParser } from "cron-parser";
5
+ import cronstrue from "cronstrue";
6
+
7
+ export interface CronInfo {
8
+ valid: boolean;
9
+ /** Human-readable summary, e.g. "Every minute" (empty when invalid). */
10
+ description: string;
11
+ /** Next fire instant in UTC (null when invalid). */
12
+ nextRun: Date | null;
13
+ /** Reason the expression was rejected (set only when `valid` is false). */
14
+ error?: string;
15
+ }
16
+
17
+ /** Valid 3-letter month and day-of-week names in UNIX cron. */
18
+ const UNIX_CRON_NAMES = new Set([
19
+ "JAN",
20
+ "FEB",
21
+ "MAR",
22
+ "APR",
23
+ "MAY",
24
+ "JUN",
25
+ "JUL",
26
+ "AUG",
27
+ "SEP",
28
+ "OCT",
29
+ "NOV",
30
+ "DEC",
31
+ "SUN",
32
+ "MON",
33
+ "TUE",
34
+ "WED",
35
+ "THU",
36
+ "FRI",
37
+ "SAT",
38
+ ]);
39
+
40
+ /**
41
+ * Reject cron-parser / Quartz extensions absent from plain UNIX cron (`L`, `W`,
42
+ * `#`, `?`). Mirrors the server's `CronEvaluator.isPlainUnixGrammar` so the UI
43
+ * preview flags the same expressions the server (and the control plane) reject,
44
+ * rather than describing a cron that would silently never arm after publish.
45
+ */
46
+ function isPlainUnixGrammar(expr: string): boolean {
47
+ for (const field of expr.trim().split(/\s+/)) {
48
+ if (/[#?]/.test(field)) return false;
49
+ for (const token of field.split(/[,\-/]/)) {
50
+ if (token === "" || token === "*") continue;
51
+ if (
52
+ /[A-Za-z]/.test(token) &&
53
+ !UNIX_CRON_NAMES.has(token.toUpperCase())
54
+ ) {
55
+ return false;
56
+ }
57
+ }
58
+ }
59
+ return true;
60
+ }
61
+
62
+ /**
63
+ * Describe a 5-field UNIX cron for display: a human-readable summary (cronstrue)
64
+ * and the next fire instant (cron-parser, in UTC — matching the publisher's
65
+ * server-side scheduler so the UI shows the same instants it will fire at).
66
+ *
67
+ * The expression is required to be exactly 5 fields and plain UNIX grammar,
68
+ * mirroring the server's `CronEvaluator`: cron-parser also accepts an optional
69
+ * leading seconds field (6 fields) and extensions (L/W/#/?), but the manifest
70
+ * contract is plain 5-field UNIX cron, so those are reported invalid rather
71
+ * than silently reinterpreted (or accepted here yet rejected after publish).
72
+ */
73
+ export function describeCron(expr: string): CronInfo {
74
+ const trimmed = (expr ?? "").trim();
75
+ if (trimmed.split(/\s+/).filter(Boolean).length !== 5) {
76
+ return {
77
+ valid: false,
78
+ description: "",
79
+ nextRun: null,
80
+ error: "Expected a 5-field UNIX cron: minute hour day-of-month month day-of-week.",
81
+ };
82
+ }
83
+ if (!isPlainUnixGrammar(trimmed)) {
84
+ return {
85
+ valid: false,
86
+ description: "",
87
+ nextRun: null,
88
+ error: "Unsupported cron syntax: L, W, #, and ? extensions are not allowed (plain 5-field UNIX cron only).",
89
+ };
90
+ }
91
+ try {
92
+ const description = cronstrue.toString(trimmed, {
93
+ use24HourTimeFormat: true,
94
+ verbose: false,
95
+ });
96
+ const nextRun = CronExpressionParser.parse(trimmed, { tz: "UTC" })
97
+ .next()
98
+ .toDate();
99
+ return { valid: true, description, nextRun };
100
+ } catch (e) {
101
+ return {
102
+ valid: false,
103
+ description: "",
104
+ nextRun: null,
105
+ error: e instanceof Error ? e.message : "Invalid cron expression.",
106
+ };
107
+ }
108
+ }
109
+
110
+ /** Absolute UTC label for a next-run instant, e.g. "Jul 14, 2026, 06:00 UTC". */
111
+ export function formatNextRun(d: Date | null): string {
112
+ if (!d) return "—";
113
+ return (
114
+ d.toLocaleString(undefined, {
115
+ year: "numeric",
116
+ month: "short",
117
+ day: "numeric",
118
+ hour: "2-digit",
119
+ minute: "2-digit",
120
+ timeZone: "UTC",
121
+ hour12: false,
122
+ }) + " UTC"
123
+ );
124
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ export { default as Materializations } from "./Materializations";
5
+ export { default as EnvironmentMaterializations } from "./EnvironmentMaterializations";
@@ -0,0 +1,145 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Materialization, MaterializationStatus } from "../../client";
5
+
6
+ /**
7
+ * Non-terminal phases of a build: PENDING (building) -> MANIFEST_ROWS_READY
8
+ * (tables built) -> MANIFEST_FILE_READY (terminal). Any non-terminal phase may
9
+ * be polled and stopped.
10
+ */
11
+ export function isActiveStatus(status?: MaterializationStatus): boolean {
12
+ return (
13
+ status === MaterializationStatus.Pending ||
14
+ status === MaterializationStatus.ManifestRowsReady
15
+ );
16
+ }
17
+
18
+ export function isTerminalStatus(status?: MaterializationStatus): boolean {
19
+ return (
20
+ status === MaterializationStatus.ManifestFileReady ||
21
+ status === MaterializationStatus.Failed ||
22
+ status === MaterializationStatus.Cancelled
23
+ );
24
+ }
25
+
26
+ /**
27
+ * Human-friendly status label. The publisher drives every phase automatically,
28
+ * so the intermediate states (PENDING / MANIFEST_ROWS_READY) both read as
29
+ * "Pending" and the terminal success state reads as "Done". Failures and
30
+ * cancellations keep their own labels.
31
+ */
32
+ export function statusLabel(status?: MaterializationStatus): string {
33
+ switch (status) {
34
+ case MaterializationStatus.ManifestFileReady:
35
+ return "Done";
36
+ case MaterializationStatus.Failed:
37
+ return "Failed";
38
+ case MaterializationStatus.Cancelled:
39
+ return "Cancelled";
40
+ case MaterializationStatus.Pending:
41
+ case MaterializationStatus.ManifestRowsReady:
42
+ return "Pending";
43
+ default:
44
+ return "Unknown";
45
+ }
46
+ }
47
+
48
+ type ChipColor = "default" | "info" | "success" | "error" | "warning";
49
+
50
+ export function statusColor(status?: MaterializationStatus): ChipColor {
51
+ switch (status) {
52
+ case MaterializationStatus.ManifestRowsReady:
53
+ return "info";
54
+ case MaterializationStatus.ManifestFileReady:
55
+ return "success";
56
+ case MaterializationStatus.Failed:
57
+ return "error";
58
+ case MaterializationStatus.Cancelled:
59
+ return "warning";
60
+ case MaterializationStatus.Pending:
61
+ default:
62
+ return "default";
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Shape of Materialization.metadata. The generated client types it as
68
+ * `object | null`, so callers must read it through parseMetadata(), which
69
+ * narrows defensively and tolerates a missing or differently-shaped object.
70
+ */
71
+ export interface MaterializationMetadata {
72
+ forceRefresh?: boolean;
73
+ sourceNames?: string[];
74
+ mode?: "auto" | "orchestrated";
75
+ /**
76
+ * What initiated the run. `SCHEDULER` = the standalone scheduler fired the
77
+ * package's `materialization.schedule` cron; `ON_DEMAND` (default) = an
78
+ * explicit API/UI create. Recorded on the run so a scheduled rebuild is
79
+ * distinguishable from a manual one.
80
+ */
81
+ trigger?: "ON_DEMAND" | "SCHEDULER";
82
+ sourcesBuilt?: number;
83
+ sourcesReused?: number;
84
+ }
85
+
86
+ export function parseMetadata(
87
+ materialization: Materialization,
88
+ ): MaterializationMetadata {
89
+ return (materialization.metadata ?? {}) as MaterializationMetadata;
90
+ }
91
+
92
+ /** Human label for how a run was initiated. */
93
+ export function triggerLabel(
94
+ meta: MaterializationMetadata,
95
+ ): "Scheduled" | "Manual" {
96
+ return meta.trigger === "SCHEDULER" ? "Scheduled" : "Manual";
97
+ }
98
+
99
+ /** Human-readable elapsed time between two ISO timestamps (to now if open). */
100
+ export function formatDuration(
101
+ startedAt?: string | null,
102
+ completedAt?: string | null,
103
+ ): string {
104
+ if (!startedAt) return "-";
105
+ const start = new Date(startedAt).getTime();
106
+ const end = completedAt ? new Date(completedAt).getTime() : Date.now();
107
+ const totalMs = Math.max(0, end - start);
108
+ if (totalMs < 1000) return `${totalMs}ms`;
109
+ const seconds = Math.round(totalMs / 1000);
110
+ if (seconds < 60) return `${seconds}s`;
111
+ const minutes = Math.floor(seconds / 60);
112
+ const remSeconds = seconds % 60;
113
+ if (minutes < 60) return `${minutes}m ${remSeconds}s`;
114
+ const hours = Math.floor(minutes / 60);
115
+ const remMinutes = minutes % 60;
116
+ return `${hours}h ${remMinutes}m`;
117
+ }
118
+
119
+ /** Absolute, locale-formatted timestamp (e.g. "Jun 19, 2026, 3:33 PM"). */
120
+ export function formatTimestamp(iso?: string | null): string {
121
+ if (!iso) return "—";
122
+ const date = new Date(iso);
123
+ if (Number.isNaN(date.getTime())) return "—";
124
+ return date.toLocaleString(undefined, {
125
+ year: "numeric",
126
+ month: "short",
127
+ day: "numeric",
128
+ hour: "numeric",
129
+ minute: "2-digit",
130
+ });
131
+ }
132
+
133
+ /** Compact relative timestamp, e.g. "just now", "5m ago", "2h ago", "3d ago". */
134
+ export function formatRelativeTime(iso?: string | null): string {
135
+ if (!iso) return "-";
136
+ const then = new Date(iso).getTime();
137
+ const seconds = Math.round((Date.now() - then) / 1000);
138
+ if (seconds < 60) return "just now";
139
+ const minutes = Math.floor(seconds / 60);
140
+ if (minutes < 60) return `${minutes}m ago`;
141
+ const hours = Math.floor(minutes / 60);
142
+ if (hours < 24) return `${hours}h ago`;
143
+ const days = Math.floor(hours / 24);
144
+ return `${days}d ago`;
145
+ }
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import "@malloydata/malloy-explorer/styles.css";
2
5
  import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
3
6
  import SearchIcon from "@mui/icons-material/Search";
@@ -45,6 +48,22 @@ export default function Model({
45
48
  const [sharedSourceIndex, setSharedSourceIndex] = React.useState(0);
46
49
  const [copyMessage, setCopyMessage] = useState("");
47
50
 
51
+ // Whether the model imports other files — drives the empty-state hint for
52
+ // import-only models, whose discovery surface is legitimately empty (no
53
+ // local sources, no export{}) but whose page would otherwise render blank.
54
+ // `modelDef` is returned by the server but intentionally absent from the
55
+ // typed CompiledModel schema (internal compiler blob), hence the cast.
56
+ const modelDefJson = (data as { modelDef?: string } | undefined)?.modelDef;
57
+ const hasImports = React.useMemo(() => {
58
+ if (!modelDefJson) return false;
59
+ try {
60
+ const def = JSON.parse(modelDefJson) as { imports?: unknown[] };
61
+ return Array.isArray(def.imports) && def.imports.length > 0;
62
+ } catch {
63
+ return false;
64
+ }
65
+ }, [modelDefJson]);
66
+
48
67
  if (isLoading) {
49
68
  return <Loading text="Fetching Model..." />;
50
69
  }
@@ -114,7 +133,7 @@ export default function Model({
114
133
  <LinkOutlinedIcon
115
134
  sx={{
116
135
  fontSize: "24px",
117
- color: "#666666",
136
+ color: "text.secondary",
118
137
  cursor: "pointer",
119
138
  }}
120
139
  onClick={copyToClipboard}
@@ -150,7 +169,7 @@ export default function Model({
150
169
  <SearchIcon
151
170
  sx={{
152
171
  fontSize: "18px",
153
- color: "#666666",
172
+ color: "text.secondary",
154
173
  marginBottom: "5px",
155
174
  }}
156
175
  />
@@ -196,6 +215,29 @@ export default function Model({
196
215
  </Stack>
197
216
  )}
198
217
 
218
+ {/* Empty discovery surface: nothing exported, nothing to render.
219
+ For import-only models, say why and how to fix it — otherwise
220
+ the page reads as broken. */}
221
+ {(!Array.isArray(data?.sourceInfos) ||
222
+ data.sourceInfos.length === 0) &&
223
+ !(data?.queries && data.queries.length > 0) && (
224
+ <Box sx={{ textAlign: "center", py: 6 }}>
225
+ <Typography
226
+ variant="body1"
227
+ sx={{ color: "text.secondary", marginBottom: "8px" }}
228
+ >
229
+ This model exposes no sources or queries.
230
+ </Typography>
231
+ {hasImports && (
232
+ <Typography variant="body2" color="text.secondary">
233
+ It imports other files but re-exports nothing. Add{" "}
234
+ <code>export {"{ source_name }"}</code> to surface
235
+ imported sources here.
236
+ </Typography>
237
+ )}
238
+ </Box>
239
+ )}
240
+
199
241
  {/* Model Explorer Dialog */}
200
242
  <ModelExplorerDialog
201
243
  open={dialogOpen}
@@ -1,9 +1,14 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import PlayArrowIcon from "@mui/icons-material/PlayArrow";
2
5
  import SearchIcon from "@mui/icons-material/Search";
3
6
  import { Box, Button, IconButton, Typography } from "@mui/material";
4
7
  import React, { useEffect } from "react";
5
8
  import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
9
+ import { usePublisherTheme } from "../../theme/ThemeContext";
6
10
  import { parseResourceUri } from "../../utils/formatting";
11
+ import { CHART_RESULT_QUERY_OPTIONS } from "../../utils/queryClient";
7
12
  import { highlight } from "../highlighter";
8
13
  import ResultContainer from "../RenderedResult/ResultContainer";
9
14
  import ResultsDialog from "../ResultsDialog";
@@ -32,7 +37,7 @@ export function ModelCell({
32
37
  const [resultsDialogOpen, setResultsDialogOpen] = React.useState(false);
33
38
  const [hasRun, setHasRun] = React.useState(false);
34
39
 
35
- const { packageName, projectName, versionId, modelPath } =
40
+ const { packageName, environmentName, versionId, modelPath } =
36
41
  parseResourceUri(resourceUri);
37
42
  const { apiClients } = useServer();
38
43
 
@@ -44,7 +49,7 @@ export function ModelCell({
44
49
  queryKey: ["namedQueryResult", resourceUri, queryName],
45
50
  queryFn: () =>
46
51
  apiClients.models.executeQueryModel(
47
- projectName,
52
+ environmentName,
48
53
  packageName,
49
54
  modelPath,
50
55
  {
@@ -55,18 +60,20 @@ export function ModelCell({
55
60
  },
56
61
  ),
57
62
  enabled: runOnDemand ? hasRun : true, // Execute on demand or always
63
+ ...CHART_RESULT_QUERY_OPTIONS,
58
64
  });
59
65
 
66
+ const { mode } = usePublisherTheme();
60
67
  useEffect(() => {
61
68
  if (annotations && annotations.length > 0) {
62
69
  const code = annotations
63
70
  .map((annotation) => `// ${annotation}`)
64
71
  .join("\n");
65
- highlight(code, "typescript").then((highlightedCode) => {
72
+ highlight(code, "typescript", mode).then((highlightedCode) => {
66
73
  setHighlightedAnnotations(highlightedCode);
67
74
  });
68
75
  }
69
- }, [annotations]);
76
+ }, [annotations, mode]);
70
77
 
71
78
  return (
72
79
  <CleanNotebookCell>
@@ -123,7 +130,7 @@ export function ModelCell({
123
130
  }}
124
131
  onClick={() => setResultsDialogOpen(true)}
125
132
  >
126
- <SearchIcon sx={{ fontSize: "18px", color: "#666666" }} />
133
+ <SearchIcon sx={{ fontSize: "18px", color: "text.secondary" }} />
127
134
  </IconButton>
128
135
  </Box>
129
136
 
@@ -177,6 +184,7 @@ export function ModelCell({
177
184
  result={queryData.data.result}
178
185
  maxHeight={600}
179
186
  maxResultSize={maxResultSize}
187
+ renderLogs={queryData.data.renderLogs}
180
188
  />
181
189
  )}
182
190
  </CleanMetricCard>
@@ -186,6 +194,7 @@ export function ModelCell({
186
194
  open={resultsDialogOpen}
187
195
  onClose={() => setResultsDialogOpen(false)}
188
196
  result={queryData?.data?.result || ""}
197
+ renderLogs={queryData?.data?.renderLogs}
189
198
  title={`Query: ${queryName}`}
190
199
  />
191
200
  </CleanNotebookCell>
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { Box, Stack } from "@mui/material";
2
5
  import Autocomplete from "@mui/material/Autocomplete";
3
6
  import TextField from "@mui/material/TextField";
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import React from "react";
2
5
  import { Dialog, DialogTitle, DialogContent, IconButton } from "@mui/material";
3
6
  import CloseIcon from "@mui/icons-material/Close";
@@ -40,7 +43,7 @@ export function ModelExplorerDialog({
40
43
  }}
41
44
  >
42
45
  {title}
43
- <IconButton onClick={onClose} sx={{ color: "#666666" }}>
46
+ <IconButton onClick={onClose} sx={{ color: "text.secondary" }}>
44
47
  <CloseIcon />
45
48
  </IconButton>
46
49
  </DialogTitle>