@malloy-publisher/sdk 0.0.37 → 0.0.39

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 (32) hide show
  1. package/dist/RenderedResult-BkosOmHn.js +79 -0
  2. package/dist/RenderedResult-Cw08MPat.cjs +1 -0
  3. package/dist/client/api.d.ts +2 -2
  4. package/dist/components/ApiErrorDisplay.d.ts +1 -1
  5. package/dist/components/Loading.d.ts +37 -0
  6. package/dist/components/index.d.ts +1 -0
  7. package/dist/{index-7mmEVMId.cjs → index-CBFYy63L.cjs} +517 -517
  8. package/dist/{index-DdtGkJIk.js → index-CgV5BrBn.js} +23194 -23152
  9. package/dist/index.cjs.js +1 -1
  10. package/dist/index.es.js +17 -16
  11. package/dist/{vendor-C6w9JpPA.js → vendor-BCM56_2K.js} +60 -59
  12. package/dist/{vendor-DAoHVNwq.cjs → vendor-Bg9-K32d.cjs} +66 -66
  13. package/package.json +1 -1
  14. package/src/components/ApiErrorDisplay.tsx +1 -3
  15. package/src/components/Home/Home.tsx +2 -3
  16. package/src/components/Loading.tsx +103 -0
  17. package/src/components/Model/Model.tsx +2 -6
  18. package/src/components/Notebook/Notebook.tsx +13 -7
  19. package/src/components/Package/Config.tsx +17 -17
  20. package/src/components/Package/Databases.tsx +2 -3
  21. package/src/components/Package/Models.tsx +8 -8
  22. package/src/components/Package/Notebooks.tsx +8 -6
  23. package/src/components/Package/Schedules.tsx +2 -5
  24. package/src/components/Project/About.tsx +2 -5
  25. package/src/components/Project/ConnectionExplorer.tsx +4 -15
  26. package/src/components/Project/Packages.tsx +2 -5
  27. package/src/components/QueryResult/QueryResult.tsx +2 -6
  28. package/src/components/RenderedResult/RenderedResult.tsx +107 -18
  29. package/src/components/RenderedResult/ResultContainer.tsx +5 -2
  30. package/src/components/index.ts +1 -0
  31. package/dist/RenderedResult-ChKXzRBq.cjs +0 -1
  32. package/dist/RenderedResult-DkEsDzXb.js +0 -51
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@malloy-publisher/sdk",
3
3
  "description": "Malloy Publisher SDK",
4
- "version": "0.0.37",
4
+ "version": "0.0.39",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -1,10 +1,9 @@
1
1
  import { Typography } from "@mui/material";
2
- import React from "react";
3
2
 
4
3
  export interface ApiError extends Error {
5
4
  status?: number;
6
5
  data?: {
7
- code: string;
6
+ code: number;
8
7
  message: string;
9
8
  };
10
9
  }
@@ -27,7 +26,6 @@ export function ApiErrorDisplay({ error, context }: ApiErrorDisplayProps) {
27
26
  style={{
28
27
  whiteSpace: "pre-wrap",
29
28
  color: "red",
30
- backgroundColor: "black",
31
29
  padding: "10px",
32
30
  margin: "auto",
33
31
  }}
@@ -1,10 +1,9 @@
1
1
  import { Grid, Typography } from "@mui/material";
2
2
  import { QueryClient, useQuery } from "@tanstack/react-query";
3
3
  import { ProjectsApi, Configuration } from "../../client";
4
- import axios from "axios";
5
4
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
5
+ import { Loading } from "../Loading";
6
6
 
7
- axios.defaults.baseURL = "http://localhost:4000";
8
7
  const projectsApi = new ProjectsApi(new Configuration());
9
8
  const queryClient = new QueryClient();
10
9
 
@@ -63,6 +62,6 @@ export default function Home({ server, navigate }: HomeProps) {
63
62
  );
64
63
  }
65
64
  } else {
66
- return <Typography variant="h6">Loading projects...</Typography>;
65
+ return <Loading text="Loading projects..." />;
67
66
  }
68
67
  }
@@ -0,0 +1,103 @@
1
+ import { Box, CircularProgress, Typography } from "@mui/material";
2
+
3
+ export interface LoadingProps {
4
+ /**
5
+ * The text to display below the spinner
6
+ */
7
+ text?: string;
8
+ /**
9
+ * The size of the CircularProgress component
10
+ * @default 20
11
+ */
12
+ size?: number | string;
13
+ /**
14
+ * The color of the CircularProgress component
15
+ * @default "primary"
16
+ */
17
+ color?:
18
+ | "primary"
19
+ | "secondary"
20
+ | "error"
21
+ | "info"
22
+ | "success"
23
+ | "warning"
24
+ | "inherit";
25
+ /**
26
+ * The thickness of the circular progress
27
+ * @default 3.6
28
+ */
29
+ thickness?: number;
30
+ /**
31
+ * Whether to center the component
32
+ * @default true
33
+ */
34
+ centered?: boolean;
35
+ /**
36
+ * Custom spacing between spinner and text
37
+ * @default 2
38
+ */
39
+ spacing?: number;
40
+ /**
41
+ * Typography variant for the text
42
+ * @default "body1"
43
+ */
44
+ textVariant?:
45
+ | "h1"
46
+ | "h2"
47
+ | "h3"
48
+ | "h4"
49
+ | "h5"
50
+ | "h6"
51
+ | "subtitle1"
52
+ | "subtitle2"
53
+ | "body1"
54
+ | "body2"
55
+ | "caption"
56
+ | "overline";
57
+ }
58
+
59
+ export function Loading({
60
+ text,
61
+ size = 20,
62
+ color = "primary",
63
+ thickness = 3.6,
64
+ centered = true,
65
+ spacing = 2,
66
+ textVariant = "body2",
67
+ }: LoadingProps) {
68
+ const content = (
69
+ <Box
70
+ sx={{
71
+ display: "flex",
72
+ flexDirection: "column",
73
+ alignItems: "center",
74
+ gap: spacing,
75
+ }}
76
+ >
77
+ <CircularProgress size={size} color={color} thickness={thickness} />
78
+ {text && (
79
+ <Typography variant={textVariant} color="text.secondary">
80
+ {text}
81
+ </Typography>
82
+ )}
83
+ </Box>
84
+ );
85
+
86
+ if (centered) {
87
+ return (
88
+ <Box
89
+ sx={{
90
+ display: "flex",
91
+ justifyContent: "center",
92
+ alignItems: "center",
93
+ minHeight: "200px",
94
+ width: "100%",
95
+ }}
96
+ >
97
+ {content}
98
+ </Box>
99
+ );
100
+ }
101
+
102
+ return content;
103
+ }
@@ -23,7 +23,7 @@ import { ApiErrorDisplay, ApiError } from "../ApiErrorDisplay";
23
23
  import "@malloydata/malloy-explorer/styles.css";
24
24
  import { usePackage } from "../Package/PackageProvider";
25
25
  import { SourceExplorerComponent } from "./SourcesExplorer";
26
- import NamedQueries from "./NamedQueries";
26
+ import { Loading } from "../Loading";
27
27
 
28
28
  const modelsApi = new ModelsApi(new Configuration());
29
29
 
@@ -118,11 +118,7 @@ export default function Model({
118
118
  );
119
119
 
120
120
  if (isLoading) {
121
- return (
122
- <Typography sx={{ p: "20px", m: "auto" }}>
123
- Fetching Model...
124
- </Typography>
125
- );
121
+ return <Loading text="Fetching Model..." />;
126
122
  }
127
123
 
128
124
  if (isError) {
@@ -10,14 +10,15 @@ import {
10
10
  } from "@mui/material";
11
11
  import Stack from "@mui/material/Stack";
12
12
  import { QueryClient, useQuery } from "@tanstack/react-query";
13
+ import { AxiosError } from "axios";
13
14
  import React, { useEffect } from "react";
14
- import { Configuration, NotebooksApi, CompiledNotebook } from "../../client";
15
+ import { CompiledNotebook, Configuration, NotebooksApi } from "../../client";
16
+ import { ApiError, ApiErrorDisplay } from "../ApiErrorDisplay";
15
17
  import { highlight } from "../highlighter";
18
+ import { Loading } from "../Loading";
16
19
  import { usePackage } from "../Package";
17
20
  import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
18
21
  import { NotebookCell } from "./NotebookCell";
19
- import { ApiErrorDisplay, ApiError } from "../ApiErrorDisplay";
20
- import { AxiosError } from "axios";
21
22
 
22
23
  const notebooksApi = new NotebooksApi(new Configuration());
23
24
  const queryClient = new QueryClient();
@@ -191,9 +192,7 @@ export default function Notebook({
191
192
  <StyledCardMedia>
192
193
  <Stack spacing={1} component="section">
193
194
  {!isSuccess && !isError && (
194
- <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
195
- Fetching Notebook...
196
- </Typography>
195
+ <Loading text="Fetching Notebook..." />
197
196
  )}
198
197
  {isSuccess &&
199
198
  notebook.notebookCells?.map((cell, index) => (
@@ -214,7 +213,14 @@ export default function Notebook({
214
213
  key={index}
215
214
  />
216
215
  ))}
217
- {isError && (
216
+ {isError && error.status === 404 && (
217
+ <Typography variant="body2">
218
+ <code>{`${projectName} > ${packageName} > ${notebookPath}`}</code>{" "}
219
+ not found.
220
+ </Typography>
221
+ )}
222
+
223
+ {isError && error.status !== 404 && (
218
224
  <ApiErrorDisplay
219
225
  error={error}
220
226
  context={`${projectName} > ${packageName} > ${notebookPath}`}
@@ -8,11 +8,11 @@ import {
8
8
  Typography,
9
9
  } from "@mui/material";
10
10
  import { QueryClient, useQuery } from "@tanstack/react-query";
11
- import axios from "axios";
12
11
  import { Configuration, PackagesApi } from "../../client";
12
+ import { ApiErrorDisplay } from "../ApiErrorDisplay";
13
+ import { Loading } from "../Loading";
13
14
  import { StyledCard, StyledCardContent } from "../styles";
14
15
  import { usePackage } from "./PackageProvider";
15
- import { ApiErrorDisplay } from "../ApiErrorDisplay";
16
16
 
17
17
  const packagesApi = new PackagesApi(new Configuration());
18
18
  const queryClient = new QueryClient();
@@ -58,7 +58,7 @@ export default function Config() {
58
58
  </ListItem>
59
59
  {!isSuccess && !isError && (
60
60
  <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
61
- Fethching Package Metadata...
61
+ <Loading text="Fetching Package Metadata..." />
62
62
  </Typography>
63
63
  )}
64
64
  {isSuccess &&
@@ -70,20 +70,20 @@ export default function Config() {
70
70
  />
71
71
  </ListItem>
72
72
  )) || (
73
- <ListItem
74
- disablePadding={true}
75
- dense={true}
76
- sx={{ mt: "20px" }}
77
- >
78
- <ErrorIcon
79
- sx={{
80
- color: "grey.600",
81
- mr: "10px",
82
- }}
83
- />
84
- <ListItemText primary={"No package manifest"} />
85
- </ListItem>
86
- ))}
73
+ <ListItem
74
+ disablePadding={true}
75
+ dense={true}
76
+ sx={{ mt: "20px" }}
77
+ >
78
+ <ErrorIcon
79
+ sx={{
80
+ color: "grey.600",
81
+ mr: "10px",
82
+ }}
83
+ />
84
+ <ListItemText primary={"No package manifest"} />
85
+ </ListItem>
86
+ ))}
87
87
  {isError && (
88
88
  <ApiErrorDisplay
89
89
  error={error}
@@ -18,6 +18,7 @@ import { Configuration, Database, DatabasesApi } from "../../client";
18
18
  import { StyledCard, StyledCardContent } from "../styles";
19
19
  import { usePackage } from "./PackageProvider";
20
20
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
21
+ import { Loading } from "../Loading";
21
22
 
22
23
  const databasesApi = new DatabasesApi(new Configuration());
23
24
  const queryClient = new QueryClient();
@@ -83,9 +84,7 @@ export default function Databases() {
83
84
  }}
84
85
  >
85
86
  {!isSuccess && !isError && (
86
- <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
87
- Fetching Databases...
88
- </Typography>
87
+ <Loading text="Fetching Databases..." />
89
88
  )}
90
89
  {isError && (
91
90
  <ApiErrorDisplay
@@ -2,10 +2,11 @@ import { Box, Divider, Typography } from "@mui/material";
2
2
  import { QueryClient, useQuery } from "@tanstack/react-query";
3
3
  import axios from "axios";
4
4
  import { Configuration, ModelsApi } from "../../client";
5
+ import { ApiErrorDisplay } from "../ApiErrorDisplay";
6
+ import { Loading } from "../Loading";
5
7
  import { StyledCard, StyledCardContent } from "../styles";
6
8
  import { FileTreeView } from "./FileTreeView";
7
9
  import { usePackage } from "./PackageProvider";
8
- import { ApiErrorDisplay } from "../ApiErrorDisplay";
9
10
 
10
11
  axios.defaults.baseURL = "http://localhost:4000";
11
12
  const modelsApi = new ModelsApi(new Configuration());
@@ -21,7 +22,7 @@ export default function Models({ navigate }: ModelsProps) {
21
22
  const { server, projectName, packageName, versionId, accessToken } =
22
23
  usePackage();
23
24
 
24
- const { data, isError, error, isLoading, isSuccess } = useQuery(
25
+ const { data, isError, error, isSuccess } = useQuery(
25
26
  {
26
27
  queryKey: ["models", server, projectName, packageName, versionId],
27
28
  queryFn: () =>
@@ -52,18 +53,14 @@ export default function Models({ navigate }: ModelsProps) {
52
53
  overflowY: "auto",
53
54
  }}
54
55
  >
55
- {!isSuccess && !isError && (
56
- <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
57
- Fetching Models...
58
- </Typography>
59
- )}
56
+ {!isSuccess && !isError && <Loading text="Fetching Models..." />}
60
57
  {isError && (
61
58
  <ApiErrorDisplay
62
59
  error={error}
63
60
  context={`${projectName} > ${packageName} > Models`}
64
61
  />
65
62
  )}
66
- {isSuccess && (
63
+ {isSuccess && data.data.length > 0 && (
67
64
  <FileTreeView
68
65
  items={data.data.sort((a, b) => {
69
66
  return a.path.localeCompare(b.path);
@@ -72,6 +69,9 @@ export default function Models({ navigate }: ModelsProps) {
72
69
  defaultExpandedItems={DEFAULT_EXPANDED_FOLDERS}
73
70
  />
74
71
  )}
72
+ {isSuccess && data.data.length === 0 && (
73
+ <Typography variant="body2">No models found.</Typography>
74
+ )}
75
75
  </Box>
76
76
  </StyledCardContent>
77
77
  </StyledCard>
@@ -1,10 +1,11 @@
1
1
  import { Box, Divider, Typography } from "@mui/material";
2
2
  import { QueryClient, useQuery } from "@tanstack/react-query";
3
3
  import { Configuration, NotebooksApi } from "../../client";
4
+ import { ApiErrorDisplay } from "../ApiErrorDisplay";
5
+ import { Loading } from "../Loading";
4
6
  import { StyledCard, StyledCardContent } from "../styles";
5
7
  import { FileTreeView } from "./FileTreeView";
6
8
  import { usePackage } from "./PackageProvider";
7
- import { ApiErrorDisplay } from "../ApiErrorDisplay";
8
9
 
9
10
  const notebooksApi = new NotebooksApi(new Configuration());
10
11
  const queryClient = new QueryClient();
@@ -19,7 +20,7 @@ export default function Notebooks({ navigate }: NotebooksProps) {
19
20
  const { server, projectName, packageName, versionId, accessToken } =
20
21
  usePackage();
21
22
 
22
- const { data, isLoading, isError, error, isSuccess } = useQuery(
23
+ const { data, isError, error, isSuccess } = useQuery(
23
24
  {
24
25
  queryKey: ["notebooks", server, projectName, packageName, versionId],
25
26
  queryFn: () =>
@@ -51,9 +52,7 @@ export default function Notebooks({ navigate }: NotebooksProps) {
51
52
  }}
52
53
  >
53
54
  {!isSuccess && !isError && (
54
- <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
55
- Fetching Notebooks...
56
- </Typography>
55
+ <Loading text="Fetching Notebooks..." />
57
56
  )}
58
57
  {isError && (
59
58
  <ApiErrorDisplay
@@ -61,7 +60,7 @@ export default function Notebooks({ navigate }: NotebooksProps) {
61
60
  context={`${projectName} > ${packageName} > Notebooks`}
62
61
  />
63
62
  )}
64
- {isSuccess && (
63
+ {isSuccess && data.data.length > 0 && (
65
64
  <FileTreeView
66
65
  items={data.data.sort((a, b) => {
67
66
  return a.path.localeCompare(b.path);
@@ -70,6 +69,9 @@ export default function Notebooks({ navigate }: NotebooksProps) {
70
69
  navigate={navigate}
71
70
  />
72
71
  )}
72
+ {isSuccess && data.data.length === 0 && (
73
+ <Typography variant="body2">No notebooks found</Typography>
74
+ )}
73
75
  </Box>
74
76
  </StyledCardContent>
75
77
  </StyledCard>
@@ -15,6 +15,7 @@ import { Configuration, SchedulesApi } from "../../client";
15
15
  import { StyledCard, StyledCardContent } from "../styles";
16
16
  import { usePackage } from "./PackageProvider";
17
17
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
18
+ import { Loading } from "../Loading";
18
19
 
19
20
  const schedulesApi = new SchedulesApi(new Configuration());
20
21
  const queryClient = new QueryClient();
@@ -41,11 +42,7 @@ export default function Schedules() {
41
42
  );
42
43
 
43
44
  if (isLoading) {
44
- return (
45
- <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
46
- Fetching Schedules...
47
- </Typography>
48
- );
45
+ return <Loading text="Fetching Schedules..." />;
49
46
  }
50
47
 
51
48
  if (isError) {
@@ -5,6 +5,7 @@ import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
5
5
  import { QueryClient, useQuery } from "@tanstack/react-query";
6
6
  import { useProject } from "./Project";
7
7
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
8
+ import { Loading } from "../Loading";
8
9
 
9
10
  const projectsApi = new ProjectsApi(new Configuration());
10
11
  const queryClient = new QueryClient();
@@ -31,11 +32,7 @@ export default function About() {
31
32
 
32
33
  return (
33
34
  <>
34
- {!isSuccess && !isError && (
35
- <Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
36
- Fetching About...
37
- </Typography>
38
- )}
35
+ {!isSuccess && !isError && <Loading text="Fetching About..." />}
39
36
  {isSuccess && (
40
37
  <StyledCard variant="outlined">
41
38
  <StyledCardContent>
@@ -26,6 +26,7 @@ import { ConnectionsApi } from "../../client/api";
26
26
  import { Configuration } from "../../client/configuration";
27
27
  import { useProject } from "./Project";
28
28
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
29
+ import { Loading } from "../Loading";
29
30
 
30
31
  const connectionsApi = new ConnectionsApi(new Configuration());
31
32
  const queryClient = new QueryClient();
@@ -92,11 +93,7 @@ export default function ConnectionExplorer({
92
93
  </Box>
93
94
  <Divider />
94
95
  <Box sx={{ mt: "10px", maxHeight: "600px", overflowY: "auto" }}>
95
- {isLoading && (
96
- <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
97
- Fetching Table Paths...
98
- </Typography>
99
- )}
96
+ {isLoading && <Loading text="Fetching Table Paths..." />}
100
97
  {isError && (
101
98
  <ApiErrorDisplay
102
99
  error={error}
@@ -242,11 +239,7 @@ function TableViewer({
242
239
  </IconButton>
243
240
  </DialogTitle>
244
241
  <DialogContent>
245
- {isLoading && (
246
- <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
247
- Fetching Table Details...
248
- </Typography>
249
- )}
242
+ {isLoading && <Loading text="Fetching Table Details..." />}
250
243
  {isError && (
251
244
  <ApiErrorDisplay
252
245
  error={error}
@@ -326,11 +319,7 @@ function TablesInSchema({
326
319
  </Typography>
327
320
  <Divider />
328
321
  <Box sx={{ mt: "10px", maxHeight: "600px", overflowY: "auto" }}>
329
- {isLoading && (
330
- <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
331
- Fetching Tables...
332
- </Typography>
333
- )}
322
+ {isLoading && <Loading text="Fetching Tables..." />}
334
323
  {isError && (
335
324
  <ApiErrorDisplay
336
325
  error={error}
@@ -4,6 +4,7 @@ import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
4
4
  import { QueryClient, useQuery } from "@tanstack/react-query";
5
5
  import { useProject } from "./Project";
6
6
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
7
+ import { Loading } from "../Loading";
7
8
 
8
9
  const packagesApi = new PackagesApi(new Configuration());
9
10
  const queryClient = new QueryClient();
@@ -34,11 +35,7 @@ export default function Packages({ navigate }: PackagesProps) {
34
35
 
35
36
  return (
36
37
  <>
37
- {!isSuccess && !isError && (
38
- <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
39
- Fetching Packages...
40
- </Typography>
41
- )}
38
+ {!isSuccess && !isError && <Loading text="Fetching Packages..." />}
42
39
  {isSuccess && (
43
40
  <StyledCard variant="outlined">
44
41
  <StyledCardContent>
@@ -1,14 +1,12 @@
1
1
  import { Suspense, lazy } from "react";
2
2
  import { Configuration, QueryresultsApi } from "../../client";
3
- import axios from "axios";
4
- import { Typography } from "@mui/material";
5
3
  import { QueryClient, useQuery } from "@tanstack/react-query";
6
4
  import { usePackage } from "../Package/PackageProvider";
7
5
  import { ApiErrorDisplay } from "../ApiErrorDisplay";
6
+ import { Loading } from "../Loading";
8
7
 
9
8
  const RenderedResult = lazy(() => import("../RenderedResult/RenderedResult"));
10
9
 
11
- axios.defaults.baseURL = "http://localhost:4000";
12
10
  const queryResultsApi = new QueryresultsApi(new Configuration());
13
11
  const queryClient = new QueryClient();
14
12
 
@@ -67,9 +65,7 @@ export default function QueryResult({
67
65
  return (
68
66
  <>
69
67
  {!isSuccess && !isError && (
70
- <Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
71
- Fetching Query Results...
72
- </Typography>
68
+ <Loading text="Fetching Query Results..." />
73
69
  )}
74
70
  {isSuccess && (
75
71
  <Suspense fallback={<div>Loading...</div>}>