@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
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import React, { useState } from "react";
2
5
  import Button from "@mui/material/Button";
3
6
  import Dialog from "@mui/material/Dialog";
@@ -13,6 +16,7 @@ import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
13
16
  import { useServer } from "../ServerProvider";
14
17
  import { useQueryClient } from "@tanstack/react-query";
15
18
  import { parseResourceUri } from "../../utils/formatting";
19
+ import { MALLOY_BRAND } from "../styles";
16
20
 
17
21
  export default function DeletePackageDialog({
18
22
  resourceUri,
@@ -32,11 +36,11 @@ export default function DeletePackageDialog({
32
36
  setOpen(false);
33
37
  onCloseDialog();
34
38
  };
35
- const { projectName, packageName } = parseResourceUri(resourceUri);
39
+ const { environmentName, packageName } = parseResourceUri(resourceUri);
36
40
 
37
41
  const deletePackage = useMutationWithApiError({
38
42
  mutationFn: () =>
39
- apiClients.packages.deletePackage(projectName, packageName),
43
+ apiClients.packages.deletePackage(environmentName, packageName),
40
44
  onSuccess() {
41
45
  handleClose();
42
46
  queryClient.invalidateQueries({ queryKey: ["packages"] });
@@ -90,8 +94,8 @@ export default function DeletePackageDialog({
90
94
  variant="outlined"
91
95
  onClick={handleClose}
92
96
  style={{
93
- borderColor: "#14b3cb",
94
- color: "#14b3cb",
97
+ borderColor: MALLOY_BRAND.teal,
98
+ color: MALLOY_BRAND.teal,
95
99
  }}
96
100
  >
97
101
  Cancel
@@ -1,19 +1,21 @@
1
- import React from "react";
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Edit } from "@mui/icons-material";
5
+ import { ListItemIcon, ListItemText, MenuItem, Snackbar } from "@mui/material";
2
6
  import Button from "@mui/material/Button";
3
- import TextField from "@mui/material/TextField";
4
7
  import Dialog from "@mui/material/Dialog";
5
8
  import DialogActions from "@mui/material/DialogActions";
6
9
  import DialogContent from "@mui/material/DialogContent";
7
10
  import DialogContentText from "@mui/material/DialogContentText";
8
11
  import DialogTitle from "@mui/material/DialogTitle";
9
- import { useState } from "react";
10
- import { Edit } from "@mui/icons-material";
11
- import { MenuItem, ListItemIcon, ListItemText, Snackbar } from "@mui/material";
12
- import { Package } from "../../client";
12
+ import TextField from "@mui/material/TextField";
13
13
  import { useQueryClient } from "@tanstack/react-query";
14
+ import React, { useState } from "react";
15
+ import { Package } from "../../client";
14
16
  import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
15
- import { useServer } from "../ServerProvider";
16
17
  import { parseResourceUri } from "../../utils/formatting";
18
+ import { useServer } from "../ServerProvider";
17
19
 
18
20
  interface EditPackageDialogProps {
19
21
  package: Package;
@@ -40,18 +42,24 @@ export default function EditPackageDialog({
40
42
  onCloseDialog();
41
43
  };
42
44
 
43
- const { packageName, projectName } = parseResourceUri(resourceUri);
45
+ const { packageName, environmentName } = parseResourceUri(resourceUri);
44
46
  const editPackage = useMutationWithApiError({
45
47
  async mutationFn(variables: { description: string }) {
46
- return apiClients.packages.updatePackage(projectName, packageName, {
47
- name: packageName,
48
- description: variables.description,
49
- });
48
+ return apiClients.packages.updatePackage(
49
+ environmentName,
50
+ packageName,
51
+ {
52
+ name: packageName,
53
+ description: variables.description,
54
+ },
55
+ );
50
56
  },
51
57
  onSuccess() {
52
58
  handleClose();
53
59
  setNotificationMessage("Package updated successfully");
54
- queryClient.invalidateQueries({ queryKey: ["packages", projectName] });
60
+ queryClient.invalidateQueries({
61
+ queryKey: ["packages", environmentName],
62
+ });
55
63
  },
56
64
  onError(error) {
57
65
  setNotificationMessage(
@@ -0,0 +1,89 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { Box, Container, Stack, Typography } from "@mui/material";
5
+ import { useEffect } from "react";
6
+ import { parseResourceUri } from "../../utils/formatting";
7
+ import { EnvironmentMaterializations } from "../Materializations";
8
+ import { useServer } from "../ServerProvider";
9
+ import About from "./About";
10
+ import AddPackageDialog from "./AddPackageDialog";
11
+ import Connections from "./Connections";
12
+ import Packages from "./Packages";
13
+
14
+ interface EnvironmentProps {
15
+ onSelectPackage: (to: string, event?: React.MouseEvent) => void;
16
+ resourceUri: string;
17
+ }
18
+
19
+ export default function Environment({
20
+ onSelectPackage,
21
+ resourceUri,
22
+ }: EnvironmentProps) {
23
+ const { mutable } = useServer();
24
+ const { environmentName } = parseResourceUri(resourceUri);
25
+
26
+ useEffect(() => {
27
+ window.scrollTo({ top: 0, behavior: "auto" });
28
+ }, []);
29
+
30
+ return (
31
+ <Container
32
+ maxWidth={false}
33
+ sx={{ maxWidth: 1024, mx: "auto", px: 4, py: 3 }}
34
+ >
35
+ <Box sx={{ mb: 5 }}>
36
+ <Typography
37
+ variant="h4"
38
+ component="h1"
39
+ sx={{ fontWeight: 600, letterSpacing: "-0.025em", mb: 0.5 }}
40
+ >
41
+ {environmentName}
42
+ </Typography>
43
+ <Typography variant="body2" color="text.secondary">
44
+ Manage packages and database connections in this environment.
45
+ Open a package to explore its models and notebooks.
46
+ </Typography>
47
+ </Box>
48
+
49
+ <Box sx={{ mb: 5 }}>
50
+ <Stack
51
+ direction="row"
52
+ justifyContent="space-between"
53
+ alignItems="flex-start"
54
+ sx={{ mb: 3 }}
55
+ >
56
+ <Box>
57
+ <Typography
58
+ variant="h6"
59
+ sx={{ fontWeight: 600, letterSpacing: "-0.025em" }}
60
+ >
61
+ Packages
62
+ </Typography>
63
+ <Typography variant="body2" color="text.secondary">
64
+ Published packages available for use in this environment
65
+ </Typography>
66
+ </Box>
67
+ {mutable && <AddPackageDialog resourceUri={resourceUri} />}
68
+ </Stack>
69
+ <Packages
70
+ onSelectPackage={onSelectPackage}
71
+ resourceUri={resourceUri}
72
+ />
73
+ </Box>
74
+
75
+ <Box sx={{ mb: 5 }}>
76
+ <Connections resourceUri={resourceUri} />
77
+ </Box>
78
+
79
+ <Box sx={{ mb: 5 }}>
80
+ <EnvironmentMaterializations
81
+ resourceUri={resourceUri}
82
+ onClickPackageFile={onSelectPackage}
83
+ />
84
+ </Box>
85
+
86
+ <About resourceUri={resourceUri} />
87
+ </Container>
88
+ );
89
+ }
@@ -0,0 +1,206 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import { MoreVert } from "@mui/icons-material";
5
+ import Inventory2OutlinedIcon from "@mui/icons-material/Inventory2Outlined";
6
+ import {
7
+ Box,
8
+ Card,
9
+ CardContent,
10
+ Grid,
11
+ IconButton,
12
+ Menu,
13
+ Tooltip,
14
+ Typography,
15
+ } from "@mui/material";
16
+ import { useState } from "react";
17
+ import { Package } from "../../client";
18
+ import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
19
+ import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
20
+ import { ApiErrorDisplay } from "../ApiErrorDisplay";
21
+ import { Loading } from "../Loading";
22
+ import { useServer } from "../ServerProvider";
23
+ import DeletePackageDialog from "./DeletePackageDialog";
24
+ import EditPackageDialog from "./EditPackageDialog";
25
+
26
+ interface PackagesProps {
27
+ onSelectPackage: (to: string, event?: React.MouseEvent) => void;
28
+ resourceUri: string;
29
+ }
30
+
31
+ export default function Packages({
32
+ onSelectPackage,
33
+ resourceUri,
34
+ }: PackagesProps) {
35
+ const { apiClients } = useServer();
36
+ const { environmentName } = parseResourceUri(resourceUri);
37
+ const { data, isSuccess, isError, error } = useQueryWithApiError({
38
+ queryKey: ["packages", environmentName],
39
+ queryFn: () => apiClients.packages.listPackages(environmentName),
40
+ });
41
+
42
+ if (isError) {
43
+ return (
44
+ <ApiErrorDisplay
45
+ error={error}
46
+ context={`${environmentName} > Packages`}
47
+ />
48
+ );
49
+ }
50
+
51
+ if (!isSuccess) {
52
+ return <Loading text="Fetching Packages..." />;
53
+ }
54
+
55
+ const packages = [...data.data].sort((a, b) => a.name.localeCompare(b.name));
56
+
57
+ return (
58
+ <Grid container spacing={2}>
59
+ {packages.map((pkg) => {
60
+ const packageResourceUri = encodeResourceUri({
61
+ environmentName,
62
+ packageName: pkg.name,
63
+ });
64
+ return (
65
+ <Grid size={{ xs: 12, sm: 6, md: 4 }} key={pkg.name}>
66
+ <PackageCard
67
+ pkg={pkg}
68
+ packageResourceUri={packageResourceUri}
69
+ onSelectPackage={onSelectPackage}
70
+ />
71
+ </Grid>
72
+ );
73
+ })}
74
+ </Grid>
75
+ );
76
+ }
77
+
78
+ function PackageCard({
79
+ pkg,
80
+ packageResourceUri,
81
+ onSelectPackage,
82
+ }: {
83
+ pkg: Package;
84
+ packageResourceUri: string;
85
+ onSelectPackage: (to: string, event?: React.MouseEvent) => void;
86
+ }) {
87
+ const { mutable } = useServer();
88
+ const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
89
+ const menuOpen = Boolean(menuAnchorEl);
90
+
91
+ const handleClick = (event: React.MouseEvent) => {
92
+ onSelectPackage(pkg.name, event);
93
+ };
94
+
95
+ const handleMenuClick = (event: React.MouseEvent<HTMLElement>) => {
96
+ event.stopPropagation();
97
+ setMenuAnchorEl(event.currentTarget);
98
+ };
99
+
100
+ const handleMenuClose = () => {
101
+ setMenuAnchorEl(null);
102
+ };
103
+
104
+ const description = pkg.description ?? "";
105
+
106
+ return (
107
+ <Card
108
+ variant="outlined"
109
+ onClick={handleClick}
110
+ sx={{
111
+ height: "100%",
112
+ cursor: "pointer",
113
+ borderRadius: 3,
114
+ borderColor: "divider",
115
+ boxShadow: "none",
116
+ transition: "all 0.2s ease-in-out",
117
+ "&:hover": { boxShadow: 2, borderColor: "primary.main" },
118
+ }}
119
+ >
120
+ <CardContent sx={{ p: 2.5, "&:last-child": { pb: 2.5 } }}>
121
+ <Box sx={{ display: "flex", alignItems: "flex-start", gap: 1.5 }}>
122
+ <Box
123
+ sx={(theme) => ({
124
+ width: 36,
125
+ height: 36,
126
+ borderRadius: 1.5,
127
+ bgcolor:
128
+ theme.palette.mode === "dark"
129
+ ? "rgba(255, 255, 255, 0.08)"
130
+ : "grey.100",
131
+ display: "flex",
132
+ alignItems: "center",
133
+ justifyContent: "center",
134
+ flexShrink: 0,
135
+ color: "text.primary",
136
+ })}
137
+ >
138
+ <Inventory2OutlinedIcon sx={{ fontSize: 20 }} />
139
+ </Box>
140
+ <Box sx={{ flex: 1, minWidth: 0 }}>
141
+ <Typography
142
+ variant="subtitle1"
143
+ component="h6"
144
+ noWrap
145
+ sx={{ fontWeight: 600, mb: 0.5 }}
146
+ >
147
+ {pkg.name}
148
+ </Typography>
149
+ <Tooltip title={description} followCursor enterDelay={1000}>
150
+ <Typography
151
+ variant="body2"
152
+ color="text.secondary"
153
+ sx={{
154
+ overflow: "hidden",
155
+ textOverflow: "ellipsis",
156
+ display: "-webkit-box",
157
+ WebkitLineClamp: 2,
158
+ WebkitBoxOrient: "vertical",
159
+ lineHeight: 1.5,
160
+ }}
161
+ >
162
+ {description}
163
+ </Typography>
164
+ </Tooltip>
165
+ </Box>
166
+ {mutable && (
167
+ <>
168
+ <IconButton
169
+ size="small"
170
+ onClick={handleMenuClick}
171
+ aria-label={`Package actions for ${pkg.name}`}
172
+ sx={{ flexShrink: 0, mt: -0.5, mr: -0.5 }}
173
+ >
174
+ <MoreVert fontSize="small" />
175
+ </IconButton>
176
+ <Menu
177
+ anchorEl={menuAnchorEl}
178
+ open={menuOpen}
179
+ onClose={handleMenuClose}
180
+ onClick={(e) => e.stopPropagation()}
181
+ anchorOrigin={{
182
+ vertical: "bottom",
183
+ horizontal: "right",
184
+ }}
185
+ transformOrigin={{
186
+ vertical: "top",
187
+ horizontal: "right",
188
+ }}
189
+ >
190
+ <EditPackageDialog
191
+ package={pkg}
192
+ resourceUri={packageResourceUri}
193
+ onCloseDialog={handleMenuClose}
194
+ />
195
+ <DeletePackageDialog
196
+ resourceUri={packageResourceUri}
197
+ onCloseDialog={handleMenuClose}
198
+ />
199
+ </Menu>
200
+ </>
201
+ )}
202
+ </Box>
203
+ </CardContent>
204
+ </Card>
205
+ );
206
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ export { default as Environment } from "./Environment";
5
+ export { default as Packages } from "./Packages";
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import { AddCircleRounded } from "@mui/icons-material";
2
5
  import Button from "@mui/material/Button";
3
6
  import Dialog from "@mui/material/Dialog";
@@ -10,10 +13,10 @@ import TextField from "@mui/material/TextField";
10
13
  import { useQueryClient } from "@tanstack/react-query";
11
14
  import React, { useState } from "react";
12
15
  import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
13
- import { generateProjectReadme } from "../../utils/parsing";
16
+ import { generateEnvironmentReadme } from "../../utils/parsing";
14
17
  import { useServer } from "../ServerProvider";
15
18
 
16
- export default function AddProjectDialog() {
19
+ export default function AddEnvironmentDialog() {
17
20
  const [open, setOpen] = useState(false);
18
21
  const { apiClients } = useServer();
19
22
  const [notificationMessage, setNotificationMessage] = useState("");
@@ -25,11 +28,11 @@ export default function AddProjectDialog() {
25
28
  setOpen(false);
26
29
  };
27
30
  const queryClient = useQueryClient();
28
- const addProject = useMutationWithApiError({
31
+ const addEnvironment = useMutationWithApiError({
29
32
  async mutationFn(variables: { name: string; description: string }) {
30
- return apiClients.projects.createProject({
33
+ return apiClients.environments.createEnvironment({
31
34
  name: variables.name,
32
- readme: generateProjectReadme(
35
+ readme: generateEnvironmentReadme(
33
36
  {
34
37
  name: variables.name,
35
38
  readme: "",
@@ -40,8 +43,8 @@ export default function AddProjectDialog() {
40
43
  },
41
44
  onSuccess() {
42
45
  handleClose();
43
- queryClient.invalidateQueries({ queryKey: ["projects"] });
44
- setNotificationMessage("Project created successfully");
46
+ queryClient.invalidateQueries({ queryKey: ["environments"] });
47
+ setNotificationMessage("Environment created successfully");
45
48
  },
46
49
  onError(error) {
47
50
  setNotificationMessage(
@@ -61,7 +64,7 @@ export default function AddProjectDialog() {
61
64
  if (!name) {
62
65
  throw new Error("Name is required");
63
66
  }
64
- addProject.mutate({ name, description });
67
+ addEnvironment.mutate({ name, description });
65
68
  };
66
69
 
67
70
  return (
@@ -70,25 +73,25 @@ export default function AddProjectDialog() {
70
73
  variant="contained"
71
74
  onClick={handleClickOpen}
72
75
  startIcon={<AddCircleRounded />}
73
- sx={{ mt: 2, color: "white" }}
76
+ sx={{ mt: 2 }}
74
77
  >
75
- Create New Project
78
+ Create New Environment
76
79
  </Button>
77
80
  <Dialog open={open} onClose={handleClose}>
78
- <DialogTitle>Create New Project</DialogTitle>
81
+ <DialogTitle>Create New Environment</DialogTitle>
79
82
  <DialogContent>
80
83
  <DialogContentText>
81
- Add a new project to start exploring semantic models and
84
+ Add a new environment to start exploring semantic models and
82
85
  analyzing data.
83
86
  </DialogContentText>
84
- <form onSubmit={handleSubmit} id="project-form">
87
+ <form onSubmit={handleSubmit} id="environment-form">
85
88
  <TextField
86
89
  autoFocus
87
90
  required
88
91
  margin="dense"
89
92
  id="name"
90
93
  name="name"
91
- label="Project Name"
94
+ label="Environment Name"
92
95
  type="text"
93
96
  fullWidth
94
97
  variant="standard"
@@ -97,7 +100,7 @@ export default function AddProjectDialog() {
97
100
  margin="dense"
98
101
  id="description"
99
102
  name="description"
100
- label="Project Description"
103
+ label="Environment Description"
101
104
  placeholder="Explore semantic models, run queries, and build dashboards"
102
105
  type="text"
103
106
  fullWidth
@@ -106,15 +109,18 @@ export default function AddProjectDialog() {
106
109
  </form>
107
110
  </DialogContent>
108
111
  <DialogActions>
109
- <Button disabled={addProject.isPending} onClick={handleClose}>
112
+ <Button
113
+ disabled={addEnvironment.isPending}
114
+ onClick={handleClose}
115
+ >
110
116
  Cancel
111
117
  </Button>
112
118
  <Button
113
119
  type="submit"
114
- form="project-form"
115
- loading={addProject.isPending}
120
+ form="environment-form"
121
+ loading={addEnvironment.isPending}
116
122
  >
117
- Create Project
123
+ Create Environment
118
124
  </Button>
119
125
  </DialogActions>
120
126
  </Dialog>
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
1
4
  import React, { useState } from "react";
2
5
  import Button from "@mui/material/Button";
3
6
  import Dialog from "@mui/material/Dialog";
@@ -9,16 +12,17 @@ import CloseIcon from "@mui/icons-material/Close";
9
12
  import Typography from "@mui/material/Typography";
10
13
  import { ListItemIcon, ListItemText, MenuItem, Snackbar } from "@mui/material";
11
14
  import { Delete } from "@mui/icons-material";
12
- import { Project } from "../../client";
15
+ import { Environment } from "../../client";
13
16
  import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
14
17
  import { useServer } from "../ServerProvider";
15
18
  import { useQueryClient } from "@tanstack/react-query";
19
+ import { MALLOY_BRAND } from "../styles";
16
20
 
17
- export default function DeleteProjectDialog({
18
- project,
21
+ export default function DeleteEnvironmentDialog({
22
+ environment,
19
23
  onCloseDialog,
20
24
  }: {
21
- project: Project;
25
+ environment: Environment;
22
26
  onCloseDialog: () => void;
23
27
  }) {
24
28
  const [open, setOpen] = useState(false);
@@ -33,12 +37,13 @@ export default function DeleteProjectDialog({
33
37
  onCloseDialog();
34
38
  };
35
39
 
36
- const deleteProject = useMutationWithApiError({
37
- mutationFn: () => apiClients.projects.deleteProject(project.name),
40
+ const deleteEnvironment = useMutationWithApiError({
41
+ mutationFn: () =>
42
+ apiClients.environments.deleteEnvironment(environment.name),
38
43
  onSuccess() {
39
44
  handleClose();
40
- queryClient.invalidateQueries({ queryKey: ["projects"] });
41
- setNotificationMessage("Project deleted successfully");
45
+ queryClient.invalidateQueries({ queryKey: ["environments"] });
46
+ setNotificationMessage("Environment deleted successfully");
42
47
  },
43
48
  onError(error) {
44
49
  setNotificationMessage(
@@ -63,7 +68,7 @@ export default function DeleteProjectDialog({
63
68
  open={open}
64
69
  >
65
70
  <DialogTitle sx={{ m: 0, p: 2 }} id="customized-dialog-title">
66
- Delete Project
71
+ Delete Environment
67
72
  </DialogTitle>
68
73
  <IconButton
69
74
  aria-label="close"
@@ -79,8 +84,8 @@ export default function DeleteProjectDialog({
79
84
  </IconButton>
80
85
  <DialogContent dividers>
81
86
  <Typography gutterBottom>
82
- Are you sure you want to delete &quot;{project.name}&quot;?
83
- This action cannot be undone.
87
+ Are you sure you want to delete &quot;{environment.name}
88
+ &quot;? This action cannot be undone.
84
89
  </Typography>
85
90
  </DialogContent>
86
91
  <DialogActions>
@@ -88,17 +93,17 @@ export default function DeleteProjectDialog({
88
93
  variant="outlined"
89
94
  onClick={handleClose}
90
95
  style={{
91
- borderColor: "#14b3cb",
92
- color: "#14b3cb",
96
+ borderColor: MALLOY_BRAND.teal,
97
+ color: MALLOY_BRAND.teal,
93
98
  }}
94
99
  >
95
100
  Cancel
96
101
  </Button>
97
102
  <Button
98
- loading={deleteProject.isPending}
103
+ loading={deleteEnvironment.isPending}
99
104
  variant="contained"
100
105
  autoFocus
101
- onClick={() => deleteProject.mutate()}
106
+ onClick={() => deleteEnvironment.mutate()}
102
107
  color="error"
103
108
  >
104
109
  Delete