@malloy-publisher/sdk 0.0.45 → 0.0.48

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 (48) hide show
  1. package/dist/{RenderedResult-wM3HaFcq.js → RenderedResult-C-inxkIP.js} +2 -2
  2. package/dist/{RenderedResult-qA34vdbd.cjs → RenderedResult-CW3J1ORR.cjs} +1 -1
  3. package/dist/components/AnalyzePackageButton.d.ts +5 -0
  4. package/dist/components/Home/Home.d.ts +1 -2
  5. package/dist/components/MutableNotebook/MutableNotebookList.d.ts +6 -0
  6. package/dist/components/MutableNotebook/index.d.ts +2 -1
  7. package/dist/components/Package/PackageProvider.d.ts +1 -3
  8. package/dist/components/Project/Project.d.ts +1 -3
  9. package/dist/components/ServerProvider.d.ts +12 -0
  10. package/dist/components/index.d.ts +3 -0
  11. package/dist/hooks/useQueryWithApiError.d.ts +4 -3
  12. package/dist/{index-nsXS-gBw.cjs → index-CcsVBhrp.cjs} +595 -610
  13. package/dist/{index-ClVlSQMk.js → index-LVZKfoHS.js} +26844 -26748
  14. package/dist/index.cjs.js +1 -1
  15. package/dist/index.es.js +26 -22
  16. package/dist/{vendor-BKsYdkmG.js → vendor-9erH7dIW.js} +20810 -24650
  17. package/dist/vendor-C4KRaQNJ.cjs +245 -0
  18. package/package.json +1 -1
  19. package/src/components/AnalyzePackageButton.tsx +185 -0
  20. package/src/components/Home/Home.tsx +3 -10
  21. package/src/components/Model/Model.tsx +6 -26
  22. package/src/components/Model/ModelCell.tsx +0 -16
  23. package/src/components/Model/NamedQueries.tsx +3 -10
  24. package/src/components/Model/SourcesExplorer.tsx +3 -10
  25. package/src/components/MutableNotebook/ModelPicker.tsx +4 -11
  26. package/src/components/MutableNotebook/MutableNotebook.tsx +4 -3
  27. package/src/components/MutableNotebook/MutableNotebookList.tsx +69 -0
  28. package/src/components/MutableNotebook/index.ts +3 -3
  29. package/src/components/Notebook/Notebook.tsx +6 -44
  30. package/src/components/Package/Config.tsx +10 -11
  31. package/src/components/Package/Connections.tsx +3 -10
  32. package/src/components/Package/Databases.tsx +9 -11
  33. package/src/components/Package/Models.tsx +4 -12
  34. package/src/components/Package/Notebooks.tsx +6 -15
  35. package/src/components/Package/Package.tsx +0 -1
  36. package/src/components/Package/PackageProvider.tsx +1 -7
  37. package/src/components/Package/Schedules.tsx +9 -11
  38. package/src/components/Project/About.tsx +3 -10
  39. package/src/components/Project/ConnectionExplorer.tsx +16 -36
  40. package/src/components/Project/Packages.tsx +3 -10
  41. package/src/components/Project/Project.tsx +1 -5
  42. package/src/components/QueryResult/QueryResult.tsx +3 -11
  43. package/src/components/ServerProvider.tsx +37 -0
  44. package/src/components/index.ts +3 -0
  45. package/src/hooks/useQueryWithApiError.ts +28 -5
  46. package/vite.config.ts +1 -1
  47. package/dist/vendor-hHfbZ4ZT.cjs +0 -342
  48. package/vite.config.ts.timestamp-1732998513502-40117fb4923d1.mjs +0 -55
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.45",
4
+ "version": "0.0.48",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.es.js",
@@ -0,0 +1,185 @@
1
+ import { Add, Launch } from "@mui/icons-material";
2
+ import {
3
+ Button,
4
+ Menu,
5
+ MenuItem,
6
+ ListItemIcon,
7
+ ListItemText,
8
+ Typography,
9
+ Dialog,
10
+ DialogTitle,
11
+ DialogContent,
12
+ FormControl,
13
+ TextField,
14
+ } from "@mui/material";
15
+ import {
16
+ NotebookStorageProvider,
17
+ BrowserNotebookStorage,
18
+ MutableNotebookList,
19
+ } from "./MutableNotebook";
20
+ import React from "react";
21
+ import { useRouterClickHandler } from "./click_helper";
22
+
23
+ export interface AnalyzePackageButtonProps {
24
+ projectName: string;
25
+ packageName: string;
26
+ }
27
+
28
+ export function AnalyzePackageButton({
29
+ projectName,
30
+ packageName,
31
+ }: AnalyzePackageButtonProps) {
32
+ const [workbookName, setWorkbookName] = React.useState("");
33
+ const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
34
+ const [newDialogOpen, setNewDialogOpen] = React.useState(false);
35
+ const [openDialogOpen, setOpenDialogOpen] = React.useState(false);
36
+ const navigate = useRouterClickHandler();
37
+
38
+ const open = Boolean(anchorEl);
39
+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
40
+ setAnchorEl(event.currentTarget);
41
+ };
42
+ const handleMenuClose = () => {
43
+ setAnchorEl(null);
44
+ };
45
+ const handleOpenDialogClose = () => {
46
+ setOpenDialogOpen(false);
47
+ };
48
+ const handleNewDialogClose = () => {
49
+ setNewDialogOpen(false);
50
+ };
51
+
52
+ const handleNotebookClick = (notebook: string, event: React.MouseEvent) => {
53
+ setOpenDialogOpen(false);
54
+ // Navigate to the ScratchNotebookPage with anchor text for notebookPath
55
+ navigate(
56
+ `/${projectName}/${packageName}/scratchNotebook/${encodeURIComponent(notebook)}`,
57
+ event,
58
+ );
59
+ };
60
+
61
+ const createNotebookClick = (event?: React.MouseEvent) => {
62
+ setNewDialogOpen(false);
63
+ // Navigate to the ScratchNotebookPage with anchor text for notebookPath
64
+ navigate(
65
+ `/${projectName}/${packageName}/scratchNotebook/${encodeURIComponent(workbookName)}`,
66
+ event,
67
+ );
68
+ setWorkbookName("");
69
+ };
70
+
71
+ return (
72
+ <>
73
+ <Button
74
+ aria-controls={open ? "basic-menu" : undefined}
75
+ aria-haspopup="true"
76
+ aria-expanded={open ? "true" : undefined}
77
+ onClick={handleClick}
78
+ sx={{ height: "40px" }}
79
+ >
80
+ Analyze Package
81
+ </Button>
82
+ <Menu
83
+ id="basic-menu"
84
+ anchorEl={anchorEl}
85
+ open={open}
86
+ onClose={handleMenuClose}
87
+ slotProps={{
88
+ list: {
89
+ "aria-labelledby": "basic-button",
90
+ },
91
+ }}
92
+ >
93
+ <MenuItem
94
+ onClick={() => {
95
+ setNewDialogOpen(true);
96
+ handleMenuClose();
97
+ }}
98
+ >
99
+ <ListItemIcon>
100
+ <Add fontSize="small" />
101
+ </ListItemIcon>
102
+ <ListItemText>
103
+ <Typography variant="body2">New Workbook</Typography>
104
+ </ListItemText>
105
+ </MenuItem>
106
+ <MenuItem
107
+ onClick={() => {
108
+ setOpenDialogOpen(true);
109
+ handleMenuClose();
110
+ }}
111
+ >
112
+ <ListItemIcon>
113
+ <Launch fontSize="small" />
114
+ </ListItemIcon>
115
+ <ListItemText>
116
+ <Typography variant="body2">Open Workbook</Typography>
117
+ </ListItemText>
118
+ </MenuItem>
119
+ </Menu>
120
+ <Dialog
121
+ open={newDialogOpen}
122
+ onClose={handleNewDialogClose}
123
+ sx={{
124
+ "& .MuiDialog-paper": {
125
+ width: "100%",
126
+ maxWidth: "300px",
127
+ },
128
+ }}
129
+ >
130
+ <DialogTitle variant="subtitle1" sx={{ fontWeight: "medium" }}>
131
+ Create Workbook
132
+ </DialogTitle>
133
+ <DialogContent>
134
+ <FormControl
135
+ sx={{
136
+ width: "100%",
137
+ display: "flex",
138
+ alignItems: "center",
139
+ gap: 2,
140
+ }}
141
+ >
142
+ <TextField
143
+ label="Workbook Name"
144
+ value={workbookName}
145
+ onChange={(e) => setWorkbookName(e.target.value)}
146
+ sx={{
147
+ width: "100%",
148
+ maxWidth: "400px",
149
+ mt: 1,
150
+ }}
151
+ />
152
+ <Button onClick={(event) => createNotebookClick(event)}>
153
+ Create
154
+ </Button>
155
+ </FormControl>
156
+ </DialogContent>
157
+ </Dialog>
158
+ <Dialog
159
+ open={openDialogOpen}
160
+ onClose={handleOpenDialogClose}
161
+ sx={{
162
+ "& .MuiDialog-paper": {
163
+ width: "100%",
164
+ maxWidth: "300px",
165
+ },
166
+ }}
167
+ >
168
+ <DialogTitle variant="subtitle1" sx={{ fontWeight: "medium" }}>
169
+ Open Workbook
170
+ </DialogTitle>
171
+ <DialogContent>
172
+ <NotebookStorageProvider
173
+ notebookStorage={new BrowserNotebookStorage()}
174
+ userContext={{
175
+ project: projectName,
176
+ package: packageName,
177
+ }}
178
+ >
179
+ <MutableNotebookList onNotebookClick={handleNotebookClick} />
180
+ </NotebookStorageProvider>
181
+ </DialogContent>
182
+ </Dialog>
183
+ </>
184
+ );
185
+ }
@@ -7,22 +7,15 @@ import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
7
7
  const projectsApi = new ProjectsApi(new Configuration());
8
8
 
9
9
  interface HomeProps {
10
- server?: string;
11
10
  navigate?: (to: string, event?: React.MouseEvent) => void;
12
11
  }
13
12
 
14
- export default function Home({ server, navigate }: HomeProps) {
13
+ export default function Home({ navigate }: HomeProps) {
15
14
  const { data, isSuccess, isError, error } = useQueryWithApiError({
16
- queryKey: ["projects", server],
17
- queryFn: () =>
18
- projectsApi.listProjects({
19
- baseURL: server,
20
- withCredentials: true,
21
- }),
15
+ queryKey: ["projects"],
16
+ queryFn: (config) => projectsApi.listProjects(config),
22
17
  });
23
18
 
24
- console.log(JSON.stringify(data?.data, null, 2));
25
-
26
19
  if (isError) {
27
20
  return <ApiErrorDisplay error={error} context="Projects List" />;
28
21
  }
@@ -53,9 +53,8 @@ export default function Model({
53
53
  React.useState<string>();
54
54
  const [selectedTab, setSelectedTab] = React.useState(0);
55
55
 
56
- const { server, projectName, packageName, versionId, accessToken } =
57
- usePackage();
58
- const modelCodeSnippet = getModelCodeSnippet(server, packageName, modelPath);
56
+ const { projectName, packageName, versionId } = usePackage();
57
+ const modelCodeSnippet = getModelCodeSnippet(modelPath);
59
58
  useEffect(() => {
60
59
  highlight(modelCodeSnippet, "typescript").then((code) => {
61
60
  setHighlightedEmbedCode(code);
@@ -64,27 +63,14 @@ export default function Model({
64
63
 
65
64
  const { data, isError, isLoading, error } =
66
65
  useQueryWithApiError<CompiledModel>({
67
- queryKey: [
68
- "package",
69
- server,
70
- projectName,
71
- packageName,
72
- modelPath,
73
- versionId,
74
- ],
75
- queryFn: async () => {
66
+ queryKey: ["package", projectName, packageName, modelPath, versionId],
67
+ queryFn: async (config) => {
76
68
  const response = await modelsApi.getModel(
77
69
  projectName,
78
70
  packageName,
79
71
  modelPath,
80
72
  versionId,
81
- {
82
- baseURL: server,
83
- withCredentials: !accessToken,
84
- headers: {
85
- Authorization: accessToken && `Bearer ${accessToken}`,
86
- },
87
- },
73
+ config,
88
74
  );
89
75
  return response.data;
90
76
  },
@@ -254,14 +240,8 @@ export default function Model({
254
240
  );
255
241
  }
256
242
 
257
- function getModelCodeSnippet(
258
- server: string,
259
- packageName: string,
260
- modelPath: string,
261
- ): string {
243
+ function getModelCodeSnippet(modelPath: string): string {
262
244
  return `<Model
263
- server="${server}"
264
- packageName="${packageName}"
265
245
  modelPath="${modelPath}"
266
246
  accessToken={accessToken}
267
247
  />`;
@@ -17,7 +17,6 @@ import LinkOutlinedIcon from "@mui/icons-material/LinkOutlined";
17
17
  import ContentCopyIcon from "@mui/icons-material/ContentCopy";
18
18
  import { useEffect } from "react";
19
19
  import { highlight } from "../highlighter";
20
- import { usePackage } from "../Package/PackageProvider";
21
20
 
22
21
  const StyledCard = styled(Card)({
23
22
  display: "flex",
@@ -56,13 +55,7 @@ export function ModelCell({
56
55
  const [highlightedAnnotations, setHighlightedAnnotations] =
57
56
  React.useState<string>();
58
57
 
59
- const { server, projectName, packageName, versionId } = usePackage();
60
-
61
58
  const queryResultCodeSnippet = getQueryResultCodeSnippet(
62
- server,
63
- projectName,
64
- packageName,
65
- versionId,
66
59
  sourceName,
67
60
  queryName,
68
61
  );
@@ -219,19 +212,10 @@ export function ModelCell({
219
212
  }
220
213
 
221
214
  function getQueryResultCodeSnippet(
222
- server: string,
223
- projectName: string,
224
- packageName: string,
225
- versionId: string,
226
215
  sourceName: string,
227
216
  queryName: string,
228
217
  ): string {
229
218
  return `<QueryResult
230
- server="${server}"
231
- accessToken={accessToken}
232
- projectName="${projectName}"
233
- packageName="${packageName}"
234
- versionId="${versionId}"
235
219
  sourceName="${sourceName}"
236
220
  queryName="${queryName}"
237
221
  />`;
@@ -25,8 +25,7 @@ export default function NamedQueries({
25
25
  namedQueries,
26
26
  modelPath,
27
27
  }: NamedQueryProps) {
28
- const { server, projectName, packageName, versionId, accessToken } =
29
- usePackage();
28
+ const { projectName, packageName, versionId } = usePackage();
30
29
  const [namedQueryResults, setNamedQueryResults] = React.useState<
31
30
  Record<string, string>
32
31
  >({});
@@ -35,7 +34,7 @@ export default function NamedQueries({
35
34
  >({});
36
35
 
37
36
  const mutation = useMutationWithApiError({
38
- mutationFn: ({ query }: { query: Query }) => {
37
+ mutationFn: ({ query }: { query: Query }, config) => {
39
38
  const val = queryResultsApi.executeQuery(
40
39
  projectName,
41
40
  packageName,
@@ -44,13 +43,7 @@ export default function NamedQueries({
44
43
  undefined,
45
44
  query.name,
46
45
  versionId,
47
- {
48
- baseURL: server,
49
- withCredentials: !accessToken,
50
- headers: {
51
- Authorization: accessToken && `Bearer ${accessToken}`,
52
- },
53
- },
46
+ config,
54
47
  );
55
48
  return val;
56
49
  },
@@ -171,10 +171,9 @@ export function SourceExplorerComponent({
171
171
  onChange(query);
172
172
  }
173
173
  }, [onChange, query]);
174
- const { server, projectName, packageName, versionId, accessToken } =
175
- usePackage();
174
+ const { projectName, packageName, versionId } = usePackage();
176
175
  const mutation = useMutationWithApiError({
177
- mutationFn: () => {
176
+ mutationFn: (_, config) => {
178
177
  const malloy = new QueryBuilder.ASTQuery({
179
178
  source: sourceAndPath.sourceInfo,
180
179
  query: query?.malloyQuery,
@@ -192,13 +191,7 @@ export function SourceExplorerComponent({
192
191
  // sourceInfo.name,
193
192
  undefined,
194
193
  versionId,
195
- {
196
- baseURL: server,
197
- withCredentials: !accessToken,
198
- headers: {
199
- Authorization: accessToken && `Bearer ${accessToken}`,
200
- },
201
- },
194
+ config,
202
195
  );
203
196
  },
204
197
  onSuccess: (data) => {
@@ -31,18 +31,11 @@ export function ModelPicker({
31
31
  initialSelectedModels,
32
32
  onModelChange,
33
33
  }: ModelPickerProps) {
34
- const { server, projectName, packageName, versionId, accessToken } =
35
- usePackage();
34
+ const { projectName, packageName, versionId } = usePackage();
36
35
  const { data, isLoading, isSuccess, isError, error } = useQueryWithApiError({
37
- queryKey: ["models", server, projectName, packageName, versionId],
38
- queryFn: () =>
39
- modelsApi.listModels(projectName, packageName, versionId, {
40
- baseURL: server,
41
- withCredentials: !accessToken,
42
- headers: {
43
- Authorization: accessToken && `Bearer ${accessToken}`,
44
- },
45
- }),
36
+ queryKey: ["models", projectName, packageName, versionId],
37
+ queryFn: (config) =>
38
+ modelsApi.listModels(projectName, packageName, versionId, config),
46
39
  });
47
40
  const [selectedModels, setSelectedModels] = React.useState<string[]>(
48
41
  initialSelectedModels || [],
@@ -22,6 +22,7 @@ import { useRouterClickHandler } from "../click_helper";
22
22
  import { SourceAndPath } from "../Model/SourcesExplorer";
23
23
  import { NotebookManager } from "../NotebookManager";
24
24
  import { usePackage } from "../Package";
25
+ import { useServer } from "../ServerProvider";
25
26
  import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
26
27
  import { MutableCell } from "./MutableCell";
27
28
  import { useNotebookStorage } from "./NotebookStorageProvider";
@@ -50,14 +51,14 @@ export default function MutableNotebook({
50
51
  hideEmbeddingIcons,
51
52
  }: MutableNotebookProps) {
52
53
  const navigate = useRouterClickHandler();
53
- const { server, projectName, packageName, versionId, accessToken } =
54
- usePackage();
54
+ const { projectName, packageName, versionId } = usePackage();
55
+ const { server, accessToken } = useServer();
56
+ const { notebookStorage, userContext } = useNotebookStorage();
55
57
  if (!projectName || !packageName) {
56
58
  throw new Error(
57
59
  "Project and package must be provided via PubliserPackageProvider",
58
60
  );
59
61
  }
60
- const { notebookStorage, userContext } = useNotebookStorage();
61
62
  if (!notebookStorage || !userContext) {
62
63
  throw new Error(
63
64
  "Notebook storage and user context must be provided via NotebookStorageProvider",
@@ -0,0 +1,69 @@
1
+ import { Box, Divider, List, ListItem, ListItemText } from "@mui/material";
2
+ import React from "react";
3
+ import { useNotebookStorage } from "./NotebookStorageProvider";
4
+
5
+ interface MutableNotebookListProps {
6
+ onNotebookClick: (notebook: string, event: React.MouseEvent) => void;
7
+ }
8
+
9
+ export function MutableNotebookList({
10
+ onNotebookClick,
11
+ }: MutableNotebookListProps) {
12
+ const { notebookStorage, userContext } = useNotebookStorage();
13
+ const [notebooks, setNotebooks] = React.useState<string[]>([]);
14
+
15
+ React.useEffect(() => {
16
+ if (notebookStorage && userContext) {
17
+ setNotebooks(notebookStorage.listNotebooks(userContext));
18
+ }
19
+ }, [notebookStorage, userContext]);
20
+
21
+ return (
22
+ <>
23
+ <Divider />
24
+ <Box
25
+ sx={{
26
+ maxHeight: "300px",
27
+ overflow: "auto",
28
+ "&::-webkit-scrollbar": {
29
+ width: "8px",
30
+ },
31
+ "&::-webkit-scrollbar-track": {
32
+ background: "transparent",
33
+ },
34
+ "&::-webkit-scrollbar-thumb": {
35
+ background: "rgba(0,0,0,0.2)",
36
+ borderRadius: "4px",
37
+ },
38
+ }}
39
+ >
40
+ <List dense>
41
+ {notebooks.length === 0 && (
42
+ <ListItem>
43
+ <ListItemText
44
+ primary="No notebooks found."
45
+ sx={{ textAlign: "center" }}
46
+ />
47
+ </ListItem>
48
+ )}
49
+ {notebooks.map((notebook) => (
50
+ <ListItem
51
+ key={notebook}
52
+ onClick={(event: React.MouseEvent) =>
53
+ onNotebookClick(notebook, event)
54
+ }
55
+ sx={{
56
+ cursor: "pointer",
57
+ "&:hover": {
58
+ backgroundColor: "action.hover",
59
+ },
60
+ }}
61
+ >
62
+ <ListItemText primary={notebook} />
63
+ </ListItem>
64
+ ))}
65
+ </List>
66
+ </Box>
67
+ </>
68
+ );
69
+ }
@@ -1,8 +1,8 @@
1
1
  export { BrowserNotebookStorage } from "./BrowserNotebookStorage";
2
2
  export { default as MutableNotebook } from "./MutableNotebook";
3
3
  export type { NotebookStorage, UserContext } from "./NotebookStorage";
4
+ export { MutableNotebookList } from "./MutableNotebookList";
4
5
  export {
5
- default as NotebookStorageProvider,
6
- useNotebookStorage
6
+ default as NotebookStorageProvider,
7
+ useNotebookStorage,
7
8
  } from "./NotebookStorageProvider";
8
-
@@ -44,14 +44,8 @@ export default function Notebook({
44
44
  React.useState<boolean>(false);
45
45
  const [highlightedEmbedCode, setHighlightedEmbedCode] =
46
46
  React.useState<string>();
47
- const { server, projectName, packageName, accessToken, versionId } =
48
- usePackage();
49
- const notebookCodeSnippet = getNotebookCodeSnippet(
50
- server,
51
- packageName,
52
- notebookPath,
53
- true,
54
- );
47
+ const { projectName, packageName, versionId } = usePackage();
48
+ const notebookCodeSnippet = getNotebookCodeSnippet(notebookPath, true);
55
49
 
56
50
  useEffect(() => {
57
51
  highlight(notebookCodeSnippet, "typescript").then((code) => {
@@ -65,27 +59,14 @@ export default function Notebook({
65
59
  isError,
66
60
  error,
67
61
  } = useQueryWithApiError<CompiledNotebook>({
68
- queryKey: [
69
- "notebook",
70
- server,
71
- projectName,
72
- packageName,
73
- notebookPath,
74
- versionId,
75
- ],
76
- queryFn: async () => {
62
+ queryKey: ["notebook", projectName, packageName, notebookPath, versionId],
63
+ queryFn: async (config) => {
77
64
  const response = await notebooksApi.getNotebook(
78
65
  projectName,
79
66
  packageName,
80
67
  notebookPath,
81
68
  versionId,
82
- {
83
- baseURL: server,
84
- withCredentials: !accessToken,
85
- headers: {
86
- Authorization: accessToken && `Bearer ${accessToken}`,
87
- },
88
- },
69
+ config,
89
70
  );
90
71
  return response.data;
91
72
  },
@@ -177,9 +158,6 @@ export default function Notebook({
177
158
  cell={cell}
178
159
  notebookPath={notebookPath}
179
160
  queryResultCodeSnippet={getQueryResultCodeSnippet(
180
- server,
181
- projectName,
182
- packageName,
183
161
  notebookPath,
184
162
  cell.text,
185
163
  )}
@@ -209,18 +187,8 @@ export default function Notebook({
209
187
  );
210
188
  }
211
189
 
212
- function getQueryResultCodeSnippet(
213
- server: string,
214
- projectName: string,
215
- packageName: string,
216
- modelPath: string,
217
- query: string,
218
- ): string {
190
+ function getQueryResultCodeSnippet(modelPath: string, query: string): string {
219
191
  return `<QueryResult
220
- server="${server}"
221
- accessToken={accessToken}
222
- projectName="${projectName}"
223
- packageName="${packageName}"
224
192
  modelPath="${modelPath}"
225
193
  query="
226
194
  ${query}
@@ -229,17 +197,11 @@ function getQueryResultCodeSnippet(
229
197
  }
230
198
 
231
199
  function getNotebookCodeSnippet(
232
- server: string,
233
- packageName: string,
234
200
  notebookPath: string,
235
201
  expandedCodeCells: boolean,
236
202
  ): string {
237
203
  return `<Notebook
238
- server="${server}"
239
- packageName="${packageName}"
240
204
  notebookPath="${notebookPath}"
241
- versionId={versionId}
242
- accessToken={accessToken}
243
205
  expandCodeCells={${expandedCodeCells}}
244
206
  />`;
245
207
  }
@@ -17,19 +17,18 @@ import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
17
17
  const packagesApi = new PackagesApi(new Configuration());
18
18
 
19
19
  export default function Config() {
20
- const { server, projectName, packageName, versionId, accessToken } =
21
- usePackage();
20
+ const { projectName, packageName, versionId } = usePackage();
22
21
 
23
22
  const { data, isSuccess, isError, error } = useQueryWithApiError({
24
- queryKey: ["package", server, projectName, packageName, versionId],
25
- queryFn: () =>
26
- packagesApi.getPackage(projectName, packageName, versionId, false, {
27
- baseURL: server,
28
- withCredentials: !accessToken,
29
- headers: {
30
- Authorization: accessToken && `Bearer ${accessToken}`,
31
- },
32
- }),
23
+ queryKey: ["package", projectName, packageName, versionId],
24
+ queryFn: (config) =>
25
+ packagesApi.getPackage(
26
+ projectName,
27
+ packageName,
28
+ versionId,
29
+ false,
30
+ config,
31
+ ),
33
32
  });
34
33
 
35
34
  return (
@@ -31,18 +31,11 @@ function Connection({ connection }: { connection: ApiConnection }) {
31
31
  }
32
32
 
33
33
  export default function Connections() {
34
- const { server, projectName, accessToken } = usePackage();
34
+ const { projectName } = usePackage();
35
35
 
36
36
  const { data, isSuccess, isError, error } = useQueryWithApiError({
37
- queryKey: ["connections", server, projectName],
38
- queryFn: () =>
39
- connectionsApi.listConnections(projectName, {
40
- baseURL: server,
41
- withCredentials: !accessToken,
42
- headers: {
43
- Authorization: accessToken && `Bearer ${accessToken}`,
44
- },
45
- }),
37
+ queryKey: ["connections", projectName],
38
+ queryFn: (config) => connectionsApi.listConnections(projectName, config),
46
39
  });
47
40
 
48
41
  return (