@malloy-publisher/sdk 0.0.198-dev → 0.0.198-dev1

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 (45) hide show
  1. package/dist/{ServerProvider-DDScRRDc.es.js → ServerProvider-BuM1usxf.es.js} +181 -177
  2. package/dist/{ServerProvider-IhQ4aYBm.cjs.js → ServerProvider-C_Mnvmgc.cjs.js} +1 -1
  3. package/dist/client/api.d.ts +61 -4
  4. package/dist/client/index.cjs.js +1 -1
  5. package/dist/client/index.es.js +1 -1
  6. package/dist/components/Package/ContentTypeIcon.d.ts +16 -0
  7. package/dist/components/Package/index.d.ts +0 -1
  8. package/dist/components/styles.d.ts +16 -0
  9. package/dist/{core-w79IMXAG.es.js → core-DfcpQGVP.es.js} +1 -1
  10. package/dist/{core-7-3Jcsb0.cjs.js → core-yDgxkpo0.cjs.js} +1 -1
  11. package/dist/index-CMA8U4-B.cjs.js +228 -0
  12. package/dist/{index-CN0_kZSF.es.js → index-Y4ooZDYA.es.js} +17654 -20603
  13. package/dist/index.cjs.js +1 -1
  14. package/dist/index.es.js +33 -34
  15. package/package.json +5 -5
  16. package/src/components/Environment/AddPackageDialog.tsx +116 -79
  17. package/src/components/Environment/DeletePackageDialog.tsx +3 -2
  18. package/src/components/Environment/Environment.tsx +44 -23
  19. package/src/components/Environment/Packages.tsx +164 -156
  20. package/src/components/Home/DeleteEnvironmentDialog.tsx +3 -2
  21. package/src/components/Home/Home.tsx +272 -389
  22. package/src/components/Model/Model.tsx +2 -2
  23. package/src/components/Model/ModelCell.tsx +1 -1
  24. package/src/components/Model/ModelExplorerDialog.tsx +1 -1
  25. package/src/components/Model/SourcesExplorer.tsx +4 -4
  26. package/src/components/Notebook/Notebook.tsx +4 -9
  27. package/src/components/Notebook/NotebookCell.tsx +10 -7
  28. package/src/components/Package/ContentTypeIcon.tsx +79 -0
  29. package/src/components/Package/Package.tsx +387 -55
  30. package/src/components/Package/index.ts +0 -1
  31. package/src/components/QueryResult/QueryResult.tsx +1 -1
  32. package/src/components/RenderedResult/RenderedResult.tsx +9 -8
  33. package/src/components/ResultsDialog.tsx +1 -1
  34. package/src/components/styles.ts +28 -15
  35. package/dist/components/Package/Config.d.ts +0 -5
  36. package/dist/components/Package/Databases.d.ts +0 -5
  37. package/dist/components/Package/FileTreeView.d.ts +0 -9
  38. package/dist/components/Package/Models.d.ts +0 -6
  39. package/dist/components/Package/Notebooks.d.ts +0 -6
  40. package/dist/index-Xo_ADux9.cjs.js +0 -233
  41. package/src/components/Package/Config.tsx +0 -97
  42. package/src/components/Package/Databases.tsx +0 -228
  43. package/src/components/Package/FileTreeView.tsx +0 -241
  44. package/src/components/Package/Models.tsx +0 -68
  45. package/src/components/Package/Notebooks.tsx +0 -77
@@ -1,10 +1,13 @@
1
1
  import { MoreVert } from "@mui/icons-material";
2
+ import Inventory2OutlinedIcon from "@mui/icons-material/Inventory2Outlined";
2
3
  import {
3
4
  Box,
4
- Divider,
5
+ Card,
6
+ CardContent,
5
7
  Grid,
6
8
  IconButton,
7
9
  Menu,
10
+ Tooltip,
8
11
  Typography,
9
12
  } from "@mui/material";
10
13
  import { useState } from "react";
@@ -14,7 +17,6 @@ import { encodeResourceUri, parseResourceUri } from "../../utils/formatting";
14
17
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
15
18
  import { Loading } from "../Loading";
16
19
  import { useServer } from "../ServerProvider";
17
- import { PackageCard, PackageCardContent } from "../styles";
18
20
  import DeletePackageDialog from "./DeletePackageDialog";
19
21
  import EditPackageDialog from "./EditPackageDialog";
20
22
 
@@ -23,170 +25,176 @@ interface PackagesProps {
23
25
  resourceUri: string;
24
26
  }
25
27
 
26
- const PackageMenu = ({
27
- package: p,
28
- resourceUri: packageResourceUri,
29
- }: {
30
- package: Package;
31
- resourceUri: string;
32
- }) => {
33
- const { mutable } = useServer();
34
- const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
35
- const isMenuOpen = Boolean(menuAnchorEl);
36
- const openMenu = (event: React.MouseEvent<HTMLElement>) => {
37
- setMenuAnchorEl(event.currentTarget);
38
- };
39
- const closeMenu = () => {
40
- setMenuAnchorEl(null);
41
- };
42
-
43
- return (
44
- <>
45
- {mutable && (
46
- <>
47
- <IconButton
48
- aria-label={`Package actions for ${p.name}`}
49
- onClick={(event) => {
50
- event.stopPropagation();
51
- openMenu(event);
52
- }}
53
- aria-controls={isMenuOpen ? "package-menu" : undefined}
54
- aria-haspopup="true"
55
- aria-expanded={isMenuOpen ? "true" : undefined}
56
- >
57
- <MoreVert fontSize="small" />
58
- </IconButton>
59
- <Menu
60
- id="package-menu"
61
- aria-haspopup="true"
62
- aria-expanded={isMenuOpen ? "true" : undefined}
63
- open={isMenuOpen}
64
- anchorEl={menuAnchorEl}
65
- onClose={closeMenu}
66
- disableRestoreFocus
67
- anchorOrigin={{
68
- vertical: "top",
69
- horizontal: "left",
70
- }}
71
- transformOrigin={{
72
- vertical: "top",
73
- horizontal: "right",
74
- }}
75
- onClick={(event) => {
76
- event.stopPropagation();
77
- }}
78
- >
79
- <EditPackageDialog
80
- package={p}
81
- resourceUri={packageResourceUri}
82
- onCloseDialog={closeMenu}
83
- />
84
- <DeletePackageDialog
85
- resourceUri={packageResourceUri}
86
- onCloseDialog={closeMenu}
87
- />
88
- </Menu>
89
- </>
90
- )}
91
- </>
92
- );
93
- };
94
-
95
28
  export default function Packages({
96
29
  onSelectPackage,
97
30
  resourceUri,
98
31
  }: PackagesProps) {
99
32
  const { apiClients } = useServer();
100
- const { environmentName: environmentName } = parseResourceUri(resourceUri);
33
+ const { environmentName } = parseResourceUri(resourceUri);
101
34
  const { data, isSuccess, isError, error } = useQueryWithApiError({
102
35
  queryKey: ["packages", environmentName],
103
36
  queryFn: () => apiClients.packages.listPackages(environmentName),
104
37
  });
105
38
 
39
+ if (isError) {
40
+ return (
41
+ <ApiErrorDisplay
42
+ error={error}
43
+ context={`${environmentName} > Packages`}
44
+ />
45
+ );
46
+ }
47
+
48
+ if (!isSuccess) {
49
+ return <Loading text="Fetching Packages..." />;
50
+ }
51
+
52
+ const packages = [...data.data].sort((a, b) => a.name.localeCompare(b.name));
53
+
106
54
  return (
107
- <>
108
- {!isSuccess && !isError && <Loading text="Fetching Packages..." />}
109
- {isSuccess && (
110
- <Grid container spacing={3} columns={12}>
111
- {data.data
112
- .sort((a, b) => {
113
- return a.name.localeCompare(b.name);
114
- })
115
- .map((p) => {
116
- const packageResourceUri = encodeResourceUri({
117
- environmentName,
118
- packageName: p.name,
119
- });
120
- return (
121
- <Grid
122
- size={{ xs: 12, sm: 12, md: 12, lg: 4 }}
123
- key={p.name}
124
- >
125
- <PackageCard
126
- sx={{
127
- cursor: "pointer",
128
- transition: "all 0.2s ease-in-out",
129
- paddingTop: "8px",
130
- "&:hover": {
131
- boxShadow: "0 2px 6px rgba(0, 0, 0, 0.08)",
132
- transform: "translateY(-1px)",
133
- },
134
- }}
135
- onClick={(event) => {
136
- onSelectPackage(p.name, event);
137
- }}
138
- >
139
- <PackageCardContent>
140
- <Box
141
- display="flex"
142
- alignItems="center"
143
- justifyContent="space-between"
144
- sx={{
145
- marginBottom: "8px",
146
- }}
147
- >
148
- <Typography
149
- variant="overline"
150
- sx={{
151
- fontSize: "12px",
152
- fontWeight: "600",
153
- color: "primary.main",
154
- textTransform: "uppercase",
155
- letterSpacing: "0.5px",
156
- }}
157
- >
158
- {p.name}
159
- </Typography>
160
- <PackageMenu
161
- package={p}
162
- resourceUri={packageResourceUri}
163
- />
164
- </Box>
165
- <Divider sx={{ mb: 2 }} />
166
- <Box
167
- sx={{
168
- maxHeight: "120px",
169
- overflowY: "auto",
170
- mt: 2,
171
- }}
172
- >
173
- <Typography variant="body2">
174
- {p.description}
175
- </Typography>
176
- </Box>
177
- </PackageCardContent>
178
- </PackageCard>
179
- </Grid>
180
- );
181
- })}
182
- </Grid>
183
- )}
184
- {isError && (
185
- <ApiErrorDisplay
186
- error={error}
187
- context={`${environmentName} > Packages`}
188
- />
189
- )}
190
- </>
55
+ <Grid container spacing={2}>
56
+ {packages.map((pkg) => {
57
+ const packageResourceUri = encodeResourceUri({
58
+ environmentName,
59
+ packageName: pkg.name,
60
+ });
61
+ return (
62
+ <Grid size={{ xs: 12, sm: 6, md: 4 }} key={pkg.name}>
63
+ <PackageCard
64
+ pkg={pkg}
65
+ packageResourceUri={packageResourceUri}
66
+ onSelectPackage={onSelectPackage}
67
+ />
68
+ </Grid>
69
+ );
70
+ })}
71
+ </Grid>
72
+ );
73
+ }
74
+
75
+ function PackageCard({
76
+ pkg,
77
+ packageResourceUri,
78
+ onSelectPackage,
79
+ }: {
80
+ pkg: Package;
81
+ packageResourceUri: string;
82
+ onSelectPackage: (to: string, event?: React.MouseEvent) => void;
83
+ }) {
84
+ const { mutable } = useServer();
85
+ const [menuAnchorEl, setMenuAnchorEl] = useState<null | HTMLElement>(null);
86
+ const menuOpen = Boolean(menuAnchorEl);
87
+
88
+ const handleClick = (event: React.MouseEvent) => {
89
+ onSelectPackage(pkg.name, event);
90
+ };
91
+
92
+ const handleMenuClick = (event: React.MouseEvent<HTMLElement>) => {
93
+ event.stopPropagation();
94
+ setMenuAnchorEl(event.currentTarget);
95
+ };
96
+
97
+ const handleMenuClose = () => {
98
+ setMenuAnchorEl(null);
99
+ };
100
+
101
+ const description = pkg.description ?? "";
102
+
103
+ return (
104
+ <Card
105
+ variant="outlined"
106
+ onClick={handleClick}
107
+ sx={{
108
+ height: "100%",
109
+ cursor: "pointer",
110
+ borderRadius: 3,
111
+ borderColor: "divider",
112
+ boxShadow: "none",
113
+ transition: "all 0.2s ease-in-out",
114
+ "&:hover": { boxShadow: 2, borderColor: "primary.main" },
115
+ }}
116
+ >
117
+ <CardContent sx={{ p: 2.5, "&:last-child": { pb: 2.5 } }}>
118
+ <Box sx={{ display: "flex", alignItems: "flex-start", gap: 1.5 }}>
119
+ <Box
120
+ sx={{
121
+ width: 36,
122
+ height: 36,
123
+ borderRadius: 1.5,
124
+ bgcolor: "grey.100",
125
+ display: "flex",
126
+ alignItems: "center",
127
+ justifyContent: "center",
128
+ flexShrink: 0,
129
+ color: "text.primary",
130
+ }}
131
+ >
132
+ <Inventory2OutlinedIcon sx={{ fontSize: 20 }} />
133
+ </Box>
134
+ <Box sx={{ flex: 1, minWidth: 0 }}>
135
+ <Typography
136
+ variant="subtitle1"
137
+ component="h6"
138
+ noWrap
139
+ sx={{ fontWeight: 600, mb: 0.5 }}
140
+ >
141
+ {pkg.name}
142
+ </Typography>
143
+ <Tooltip title={description} followCursor enterDelay={1000}>
144
+ <Typography
145
+ variant="body2"
146
+ color="text.secondary"
147
+ sx={{
148
+ overflow: "hidden",
149
+ textOverflow: "ellipsis",
150
+ display: "-webkit-box",
151
+ WebkitLineClamp: 2,
152
+ WebkitBoxOrient: "vertical",
153
+ lineHeight: 1.5,
154
+ }}
155
+ >
156
+ {description}
157
+ </Typography>
158
+ </Tooltip>
159
+ </Box>
160
+ {mutable && (
161
+ <>
162
+ <IconButton
163
+ size="small"
164
+ onClick={handleMenuClick}
165
+ aria-label={`Package actions for ${pkg.name}`}
166
+ sx={{ flexShrink: 0, mt: -0.5, mr: -0.5 }}
167
+ >
168
+ <MoreVert fontSize="small" />
169
+ </IconButton>
170
+ <Menu
171
+ anchorEl={menuAnchorEl}
172
+ open={menuOpen}
173
+ onClose={handleMenuClose}
174
+ onClick={(e) => e.stopPropagation()}
175
+ anchorOrigin={{
176
+ vertical: "bottom",
177
+ horizontal: "right",
178
+ }}
179
+ transformOrigin={{
180
+ vertical: "top",
181
+ horizontal: "right",
182
+ }}
183
+ >
184
+ <EditPackageDialog
185
+ package={pkg}
186
+ resourceUri={packageResourceUri}
187
+ onCloseDialog={handleMenuClose}
188
+ />
189
+ <DeletePackageDialog
190
+ resourceUri={packageResourceUri}
191
+ onCloseDialog={handleMenuClose}
192
+ />
193
+ </Menu>
194
+ </>
195
+ )}
196
+ </Box>
197
+ </CardContent>
198
+ </Card>
191
199
  );
192
200
  }
@@ -13,6 +13,7 @@ import { Environment } from "../../client";
13
13
  import { useMutationWithApiError } from "../../hooks/useQueryWithApiError";
14
14
  import { useServer } from "../ServerProvider";
15
15
  import { useQueryClient } from "@tanstack/react-query";
16
+ import { MALLOY_BRAND } from "../styles";
16
17
 
17
18
  export default function DeleteEnvironmentDialog({
18
19
  environment,
@@ -89,8 +90,8 @@ export default function DeleteEnvironmentDialog({
89
90
  variant="outlined"
90
91
  onClick={handleClose}
91
92
  style={{
92
- borderColor: "#14b3cb",
93
- color: "#14b3cb",
93
+ borderColor: MALLOY_BRAND.teal,
94
+ color: MALLOY_BRAND.teal,
94
95
  }}
95
96
  >
96
97
  Cancel