@malloy-publisher/sdk 0.0.34 → 0.0.36
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.
- package/README.md +21 -0
- package/dist/{RenderedResult-CKEsEevp.js → RenderedResult-BlNz8j4d.js} +2 -2
- package/dist/{RenderedResult-9A74lwfO.cjs → RenderedResult-DphykkT6.cjs} +1 -1
- package/dist/client/api.d.ts +18 -0
- package/dist/components/ApiErrorDisplay.d.ts +13 -0
- package/dist/components/Model/ModelCell.d.ts +1 -6
- package/dist/components/Package/Config.d.ts +1 -9
- package/dist/components/Package/Connections.d.ts +1 -8
- package/dist/components/Package/Databases.d.ts +1 -9
- package/dist/components/Package/Models.d.ts +1 -6
- package/dist/components/Package/Notebooks.d.ts +2 -7
- package/dist/components/Package/Package.d.ts +1 -6
- package/dist/components/Package/PackageProvider.d.ts +14 -0
- package/dist/components/Package/Schedules.d.ts +1 -9
- package/dist/components/Package/index.d.ts +2 -1
- package/dist/components/Project/About.d.ts +1 -7
- package/dist/components/Project/ConnectionExplorer.d.ts +1 -4
- package/dist/components/Project/Packages.d.ts +2 -5
- package/dist/components/Project/Project.d.ts +11 -3
- package/dist/components/Project/index.d.ts +1 -1
- package/dist/components/QueryResult/QueryResult.d.ts +1 -6
- package/dist/{index-DahUc0AC.js → index-DvGSfdDD.js} +29197 -29339
- package/dist/{index-TNDWxBXR.cjs → index-nKbldp0y.cjs} +598 -598
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +17 -13
- package/dist/{vendor-DfRellEl.js → vendor-C8UD-eyK.js} +5 -5
- package/package.json +1 -1
- package/src/components/ApiErrorDisplay.tsx +40 -0
- package/src/components/Home/Home.tsx +8 -1
- package/src/components/Model/Model.tsx +59 -28
- package/src/components/Model/ModelCell.tsx +26 -63
- package/src/components/Model/NamedQueries.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +14 -15
- package/src/components/MutableNotebook/ModelPicker.tsx +13 -3
- package/src/components/MutableNotebook/MutableCell.tsx +5 -14
- package/src/components/MutableNotebook/MutableNotebook.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +48 -24
- package/src/components/Package/Config.tsx +10 -18
- package/src/components/Package/Connections.tsx +10 -12
- package/src/components/Package/Databases.tsx +93 -198
- package/src/components/Package/FileTreeView.tsx +21 -4
- package/src/components/Package/Models.tsx +21 -31
- package/src/components/Package/Notebooks.tsx +22 -32
- package/src/components/Package/Package.tsx +31 -89
- package/src/components/Package/PackageProvider.tsx +46 -0
- package/src/components/Package/Schedules.tsx +10 -19
- package/src/components/Package/index.ts +6 -1
- package/src/components/Project/About.tsx +7 -15
- package/src/components/Project/ConnectionExplorer.tsx +131 -52
- package/src/components/Project/Packages.tsx +12 -13
- package/src/components/Project/Project.tsx +35 -16
- package/src/components/Project/index.ts +1 -1
- package/src/components/QueryResult/QueryResult.tsx +12 -15
- package/src/components/RenderedResult/ResultContainer.tsx +0 -1
- package/dist/components/Package/PublisherPackageProvider.d.ts +0 -14
- package/dist/components/Project/TablesInSchema.d.ts +0 -10
- package/src/components/Package/PublisherPackageProvider.tsx +0 -48
- package/src/components/Project/TablesInSchema.tsx +0 -84
|
@@ -12,36 +12,33 @@ import {
|
|
|
12
12
|
DialogContent,
|
|
13
13
|
DialogTitle,
|
|
14
14
|
IconButton,
|
|
15
|
+
Switch,
|
|
16
|
+
FormControlLabel,
|
|
15
17
|
Table,
|
|
16
18
|
TableBody,
|
|
17
19
|
TableCell,
|
|
18
20
|
TableContainer,
|
|
19
21
|
TableHead,
|
|
20
22
|
TableRow,
|
|
21
|
-
Switch,
|
|
22
|
-
FormControlLabel,
|
|
23
23
|
} from "@mui/material";
|
|
24
24
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
25
25
|
import { ConnectionsApi } from "../../client/api";
|
|
26
26
|
import { Configuration } from "../../client/configuration";
|
|
27
|
-
import
|
|
27
|
+
import { useProject } from "./Project";
|
|
28
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
28
29
|
|
|
29
30
|
const connectionsApi = new ConnectionsApi(new Configuration());
|
|
30
31
|
const queryClient = new QueryClient();
|
|
31
32
|
|
|
32
33
|
interface ConnectionExplorerProps {
|
|
33
|
-
server?: string;
|
|
34
|
-
projectName: string;
|
|
35
34
|
connectionName: string;
|
|
36
|
-
accessToken?: string;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
export default function ConnectionExplorer({
|
|
40
|
-
server,
|
|
41
|
-
projectName,
|
|
42
38
|
connectionName,
|
|
43
|
-
accessToken,
|
|
44
39
|
}: ConnectionExplorerProps) {
|
|
40
|
+
const { server, projectName, accessToken } = useProject();
|
|
41
|
+
|
|
45
42
|
const [selectedTable, setSelectedTable] = React.useState<string | undefined>(
|
|
46
43
|
undefined,
|
|
47
44
|
);
|
|
@@ -61,6 +58,7 @@ export default function ConnectionExplorer({
|
|
|
61
58
|
},
|
|
62
59
|
}),
|
|
63
60
|
retry: false,
|
|
61
|
+
throwOnError: false,
|
|
64
62
|
},
|
|
65
63
|
queryClient,
|
|
66
64
|
);
|
|
@@ -100,9 +98,10 @@ export default function ConnectionExplorer({
|
|
|
100
98
|
</Typography>
|
|
101
99
|
)}
|
|
102
100
|
{isError && (
|
|
103
|
-
<
|
|
104
|
-
{
|
|
105
|
-
|
|
101
|
+
<ApiErrorDisplay
|
|
102
|
+
error={error}
|
|
103
|
+
context={`${projectName} > ${connectionName}`}
|
|
104
|
+
/>
|
|
106
105
|
)}
|
|
107
106
|
{isSuccess && data.data.length === 0 && (
|
|
108
107
|
<Typography variant="body2">No Schemas</Typography>
|
|
@@ -142,11 +141,8 @@ export default function ConnectionExplorer({
|
|
|
142
141
|
{selectedSchema && (
|
|
143
142
|
<Paper sx={{ p: 2 }}>
|
|
144
143
|
<TablesInSchema
|
|
145
|
-
server={server}
|
|
146
|
-
projectName={projectName}
|
|
147
144
|
connectionName={connectionName}
|
|
148
145
|
schemaName={selectedSchema}
|
|
149
|
-
accessToken={accessToken}
|
|
150
146
|
onTableClick={(tableName) => {
|
|
151
147
|
setSelectedTable(tableName);
|
|
152
148
|
}}
|
|
@@ -156,12 +152,9 @@ export default function ConnectionExplorer({
|
|
|
156
152
|
</Grid>
|
|
157
153
|
{selectedTable && (
|
|
158
154
|
<TableViewer
|
|
159
|
-
server={server}
|
|
160
|
-
projectName={projectName}
|
|
161
155
|
connectionName={connectionName}
|
|
162
156
|
schemaName={selectedSchema}
|
|
163
157
|
tableName={selectedTable}
|
|
164
|
-
accessToken={accessToken}
|
|
165
158
|
onClose={() => setSelectedTable(undefined)}
|
|
166
159
|
/>
|
|
167
160
|
)}
|
|
@@ -170,23 +163,20 @@ export default function ConnectionExplorer({
|
|
|
170
163
|
}
|
|
171
164
|
|
|
172
165
|
type TableViewerProps = {
|
|
173
|
-
server: string;
|
|
174
|
-
projectName: string;
|
|
175
166
|
connectionName: string;
|
|
176
167
|
schemaName: string;
|
|
177
168
|
tableName: string;
|
|
178
|
-
accessToken: string;
|
|
179
169
|
onClose: () => void;
|
|
180
170
|
};
|
|
171
|
+
|
|
181
172
|
function TableViewer({
|
|
182
|
-
server,
|
|
183
|
-
projectName,
|
|
184
173
|
connectionName,
|
|
185
174
|
schemaName,
|
|
186
175
|
tableName,
|
|
187
|
-
accessToken,
|
|
188
176
|
onClose,
|
|
189
177
|
}: TableViewerProps) {
|
|
178
|
+
const { server, projectName, accessToken } = useProject();
|
|
179
|
+
|
|
190
180
|
const { data, isSuccess, isError, error, isLoading } = useQuery(
|
|
191
181
|
{
|
|
192
182
|
queryKey: [
|
|
@@ -212,15 +202,17 @@ function TableViewer({
|
|
|
212
202
|
},
|
|
213
203
|
),
|
|
214
204
|
retry: false,
|
|
205
|
+
throwOnError: false,
|
|
215
206
|
},
|
|
216
207
|
queryClient,
|
|
217
208
|
);
|
|
209
|
+
|
|
218
210
|
if (isSuccess && data) {
|
|
219
211
|
console.log(data);
|
|
220
212
|
}
|
|
213
|
+
|
|
221
214
|
return (
|
|
222
|
-
|
|
223
|
-
<Dialog open={true} onClose={onclose} maxWidth="sm" fullWidth>
|
|
215
|
+
<Dialog open={true} onClose={onClose} maxWidth="sm" fullWidth>
|
|
224
216
|
<DialogTitle>
|
|
225
217
|
Table: {schemaName}.{tableName}
|
|
226
218
|
<Typography
|
|
@@ -228,7 +220,9 @@ function TableViewer({
|
|
|
228
220
|
variant="body2"
|
|
229
221
|
fontFamily="monospace"
|
|
230
222
|
component="span"
|
|
231
|
-
|
|
223
|
+
>
|
|
224
|
+
{tableName}
|
|
225
|
+
</Typography>
|
|
232
226
|
<IconButton
|
|
233
227
|
aria-label="close"
|
|
234
228
|
onClick={onClose}
|
|
@@ -248,32 +242,117 @@ function TableViewer({
|
|
|
248
242
|
</IconButton>
|
|
249
243
|
</DialogTitle>
|
|
250
244
|
<DialogContent>
|
|
251
|
-
|
|
252
|
-
<
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
245
|
+
{isLoading && (
|
|
246
|
+
<Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
|
|
247
|
+
Fetching Table Details...
|
|
248
|
+
</Typography>
|
|
249
|
+
)}
|
|
250
|
+
{isError && (
|
|
251
|
+
<ApiErrorDisplay
|
|
252
|
+
error={error}
|
|
253
|
+
context={`${projectName} > ${connectionName} > ${schemaName}.${tableName}`}
|
|
254
|
+
/>
|
|
255
|
+
)}
|
|
256
|
+
{isSuccess && data && (
|
|
257
|
+
<TableContainer>
|
|
258
|
+
<Table
|
|
259
|
+
size="small"
|
|
260
|
+
sx={{ "& .MuiTableCell-root": { padding: "10px" } }}
|
|
261
|
+
>
|
|
262
|
+
<TableHead>
|
|
263
|
+
<TableRow>
|
|
264
|
+
<TableCell>NAME</TableCell>
|
|
265
|
+
<TableCell>TYPE</TableCell>
|
|
266
|
+
</TableRow>
|
|
267
|
+
</TableHead>
|
|
268
|
+
<TableBody>
|
|
269
|
+
{data.data.columns?.map(
|
|
270
|
+
(column: { name: string; type: string }) => (
|
|
271
|
+
<TableRow key={column.name}>
|
|
272
|
+
<TableCell>{column.name}</TableCell>
|
|
273
|
+
<TableCell>{column.type}</TableCell>
|
|
274
|
+
</TableRow>
|
|
275
|
+
),
|
|
276
|
+
)}
|
|
277
|
+
</TableBody>
|
|
278
|
+
</Table>
|
|
279
|
+
</TableContainer>
|
|
280
|
+
)}
|
|
276
281
|
</DialogContent>
|
|
277
282
|
</Dialog>
|
|
278
283
|
);
|
|
279
284
|
}
|
|
285
|
+
|
|
286
|
+
interface TablesInSchemaProps {
|
|
287
|
+
connectionName: string;
|
|
288
|
+
schemaName: string;
|
|
289
|
+
onTableClick: (tableName: string) => void;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function TablesInSchema({
|
|
293
|
+
connectionName,
|
|
294
|
+
schemaName,
|
|
295
|
+
onTableClick,
|
|
296
|
+
}: TablesInSchemaProps) {
|
|
297
|
+
const { server, projectName, accessToken } = useProject();
|
|
298
|
+
|
|
299
|
+
const { data, isSuccess, isError, error, isLoading } = useQuery(
|
|
300
|
+
{
|
|
301
|
+
queryKey: [
|
|
302
|
+
"tablesInSchema",
|
|
303
|
+
server,
|
|
304
|
+
projectName,
|
|
305
|
+
connectionName,
|
|
306
|
+
schemaName,
|
|
307
|
+
],
|
|
308
|
+
queryFn: () =>
|
|
309
|
+
connectionsApi.listTables(projectName, connectionName, schemaName, {
|
|
310
|
+
baseURL: server,
|
|
311
|
+
withCredentials: !accessToken,
|
|
312
|
+
headers: {
|
|
313
|
+
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
314
|
+
},
|
|
315
|
+
}),
|
|
316
|
+
retry: false,
|
|
317
|
+
throwOnError: false,
|
|
318
|
+
},
|
|
319
|
+
queryClient,
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
return (
|
|
323
|
+
<>
|
|
324
|
+
<Typography variant="overline" fontWeight="bold">
|
|
325
|
+
Tables in {schemaName}
|
|
326
|
+
</Typography>
|
|
327
|
+
<Divider />
|
|
328
|
+
<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
|
+
)}
|
|
334
|
+
{isError && (
|
|
335
|
+
<ApiErrorDisplay
|
|
336
|
+
error={error}
|
|
337
|
+
context={`${projectName} > ${connectionName} > ${schemaName}`}
|
|
338
|
+
/>
|
|
339
|
+
)}
|
|
340
|
+
{isSuccess && data.data.length === 0 && (
|
|
341
|
+
<Typography variant="body2">No Tables</Typography>
|
|
342
|
+
)}
|
|
343
|
+
{isSuccess && data.data.length > 0 && (
|
|
344
|
+
<List dense disablePadding>
|
|
345
|
+
{data.data.map((tableName: string) => (
|
|
346
|
+
<ListItemButton
|
|
347
|
+
key={tableName}
|
|
348
|
+
onClick={() => onTableClick(tableName)}
|
|
349
|
+
>
|
|
350
|
+
<ListItemText primary={tableName} />
|
|
351
|
+
</ListItemButton>
|
|
352
|
+
))}
|
|
353
|
+
</List>
|
|
354
|
+
)}
|
|
355
|
+
</Box>
|
|
356
|
+
</>
|
|
357
|
+
);
|
|
358
|
+
}
|
|
@@ -2,23 +2,19 @@ import { Box, Divider, Grid, Typography } from "@mui/material";
|
|
|
2
2
|
import { Configuration, PackagesApi } from "../../client";
|
|
3
3
|
import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
|
|
4
4
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
5
|
+
import { useProject } from "./Project";
|
|
6
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
5
7
|
|
|
6
8
|
const packagesApi = new PackagesApi(new Configuration());
|
|
7
9
|
const queryClient = new QueryClient();
|
|
8
10
|
|
|
9
|
-
interface
|
|
10
|
-
server?: string;
|
|
11
|
-
projectName: string;
|
|
11
|
+
interface PackagesProps {
|
|
12
12
|
navigate: (to: string, event?: React.MouseEvent) => void;
|
|
13
|
-
accessToken?: string;
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
export default function
|
|
17
|
-
server,
|
|
18
|
-
|
|
19
|
-
navigate,
|
|
20
|
-
accessToken,
|
|
21
|
-
}: ProjectProps) {
|
|
15
|
+
export default function Packages({ navigate }: PackagesProps) {
|
|
16
|
+
const { server, projectName, accessToken } = useProject();
|
|
17
|
+
|
|
22
18
|
const { data, isSuccess, isError, error } = useQuery(
|
|
23
19
|
{
|
|
24
20
|
queryKey: ["packages", server, projectName],
|
|
@@ -30,6 +26,8 @@ export default function Project({
|
|
|
30
26
|
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
31
27
|
},
|
|
32
28
|
}),
|
|
29
|
+
retry: false,
|
|
30
|
+
throwOnError: false,
|
|
33
31
|
},
|
|
34
32
|
queryClient,
|
|
35
33
|
);
|
|
@@ -100,9 +98,10 @@ export default function Project({
|
|
|
100
98
|
</StyledCard>
|
|
101
99
|
)}
|
|
102
100
|
{isError && (
|
|
103
|
-
<
|
|
104
|
-
{error
|
|
105
|
-
|
|
101
|
+
<ApiErrorDisplay
|
|
102
|
+
error={error}
|
|
103
|
+
context={`${projectName} > Packages`}
|
|
104
|
+
/>
|
|
106
105
|
)}
|
|
107
106
|
</>
|
|
108
107
|
);
|
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
import { Grid } from "@mui/material";
|
|
2
2
|
import About from "./About";
|
|
3
3
|
import Packages from "./Packages";
|
|
4
|
+
import { createContext, useContext, ReactNode } from "react";
|
|
4
5
|
|
|
5
|
-
interface
|
|
6
|
+
export interface ProjectContextProps {
|
|
6
7
|
server?: string;
|
|
7
8
|
projectName: string;
|
|
8
|
-
navigate: (to: string, event?: React.MouseEvent) => void;
|
|
9
9
|
accessToken?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const ProjectContext = createContext<ProjectContextProps | undefined>(
|
|
13
|
+
undefined,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
interface ProjectProviderProps extends ProjectContextProps {
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ProjectProvider = ({
|
|
13
21
|
server,
|
|
14
22
|
projectName,
|
|
15
|
-
navigate,
|
|
16
23
|
accessToken,
|
|
17
|
-
|
|
24
|
+
children,
|
|
25
|
+
}: ProjectProviderProps) => {
|
|
26
|
+
return (
|
|
27
|
+
<ProjectContext.Provider value={{ server, projectName, accessToken }}>
|
|
28
|
+
{children}
|
|
29
|
+
</ProjectContext.Provider>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function useProject() {
|
|
34
|
+
const context = useContext(ProjectContext);
|
|
35
|
+
if (!context) {
|
|
36
|
+
throw new Error("useProject must be used within a ProjectProvider");
|
|
37
|
+
}
|
|
38
|
+
return context;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ProjectProps {
|
|
42
|
+
navigate: (to: string, event?: React.MouseEvent) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default function Project({ navigate }: ProjectProps) {
|
|
18
46
|
return (
|
|
19
47
|
<Grid
|
|
20
48
|
container
|
|
@@ -23,19 +51,10 @@ export default function Project({
|
|
|
23
51
|
sx={{ mb: (theme) => theme.spacing(2) }}
|
|
24
52
|
>
|
|
25
53
|
<Grid size={{ xs: 12, md: 12 }}>
|
|
26
|
-
<Packages
|
|
27
|
-
server={server}
|
|
28
|
-
projectName={projectName}
|
|
29
|
-
navigate={navigate}
|
|
30
|
-
accessToken={accessToken}
|
|
31
|
-
/>
|
|
54
|
+
<Packages navigate={navigate} />
|
|
32
55
|
</Grid>
|
|
33
56
|
<Grid size={{ xs: 12, md: 12 }}>
|
|
34
|
-
<About
|
|
35
|
-
server={server}
|
|
36
|
-
projectName={projectName}
|
|
37
|
-
accessToken={accessToken}
|
|
38
|
-
/>
|
|
57
|
+
<About />
|
|
39
58
|
</Grid>
|
|
40
59
|
</Grid>
|
|
41
60
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Project } from "./Project";
|
|
1
|
+
export { default as Project, ProjectProvider, useProject } from "./Project";
|
|
@@ -3,6 +3,8 @@ import { Configuration, QueryresultsApi } from "../../client";
|
|
|
3
3
|
import axios from "axios";
|
|
4
4
|
import { Typography } from "@mui/material";
|
|
5
5
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { usePackage } from "../Package/PackageProvider";
|
|
7
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
6
8
|
|
|
7
9
|
const RenderedResult = lazy(() => import("../RenderedResult/RenderedResult"));
|
|
8
10
|
|
|
@@ -11,28 +13,21 @@ const queryResultsApi = new QueryresultsApi(new Configuration());
|
|
|
11
13
|
const queryClient = new QueryClient();
|
|
12
14
|
|
|
13
15
|
interface QueryResultProps {
|
|
14
|
-
server?: string;
|
|
15
|
-
projectName: string;
|
|
16
|
-
packageName: string;
|
|
17
16
|
modelPath: string;
|
|
18
|
-
versionId?: string;
|
|
19
17
|
query?: string;
|
|
20
18
|
sourceName?: string;
|
|
21
19
|
queryName?: string;
|
|
22
|
-
accessToken?: string;
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
export default function QueryResult({
|
|
26
|
-
server,
|
|
27
|
-
projectName,
|
|
28
|
-
packageName,
|
|
29
23
|
modelPath,
|
|
30
|
-
versionId,
|
|
31
24
|
query,
|
|
32
25
|
sourceName,
|
|
33
26
|
queryName,
|
|
34
|
-
accessToken,
|
|
35
27
|
}: QueryResultProps) {
|
|
28
|
+
const { server, projectName, packageName, versionId, accessToken } =
|
|
29
|
+
usePackage();
|
|
30
|
+
|
|
36
31
|
const { data, isSuccess, isError, error } = useQuery(
|
|
37
32
|
{
|
|
38
33
|
queryKey: [
|
|
@@ -45,7 +40,6 @@ export default function QueryResult({
|
|
|
45
40
|
query,
|
|
46
41
|
sourceName,
|
|
47
42
|
queryName,
|
|
48
|
-
accessToken,
|
|
49
43
|
],
|
|
50
44
|
queryFn: () =>
|
|
51
45
|
queryResultsApi.executeQuery(
|
|
@@ -64,6 +58,8 @@ export default function QueryResult({
|
|
|
64
58
|
},
|
|
65
59
|
},
|
|
66
60
|
),
|
|
61
|
+
retry: false,
|
|
62
|
+
throwOnError: false,
|
|
67
63
|
},
|
|
68
64
|
queryClient,
|
|
69
65
|
);
|
|
@@ -76,14 +72,15 @@ export default function QueryResult({
|
|
|
76
72
|
</Typography>
|
|
77
73
|
)}
|
|
78
74
|
{isSuccess && (
|
|
79
|
-
<Suspense fallback=
|
|
75
|
+
<Suspense fallback={<div>Loading...</div>}>
|
|
80
76
|
<RenderedResult result={data.data.result} />
|
|
81
77
|
</Suspense>
|
|
82
78
|
)}
|
|
83
79
|
{isError && (
|
|
84
|
-
<
|
|
85
|
-
{`${projectName} > ${packageName} > ${modelPath}
|
|
86
|
-
|
|
80
|
+
<ApiErrorDisplay
|
|
81
|
+
context={`${projectName} > ${packageName} > ${modelPath}`}
|
|
82
|
+
error={error}
|
|
83
|
+
/>
|
|
87
84
|
)}
|
|
88
85
|
</>
|
|
89
86
|
);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export interface PublisherPackageContextProps {
|
|
3
|
-
server?: string;
|
|
4
|
-
projectName: string;
|
|
5
|
-
packageName: string;
|
|
6
|
-
versionId?: string;
|
|
7
|
-
accessToken?: string;
|
|
8
|
-
}
|
|
9
|
-
interface PublisherPackageProviderProps extends PublisherPackageContextProps {
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
}
|
|
12
|
-
export declare const PublisherPackageProvider: ({ server, projectName, packageName, versionId, accessToken, children, }: PublisherPackageProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export declare function usePublisherPackage(): PublisherPackageContextProps;
|
|
14
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
interface TablesInSchemaProps {
|
|
2
|
-
server?: string;
|
|
3
|
-
projectName: string;
|
|
4
|
-
connectionName: string;
|
|
5
|
-
schemaName: string;
|
|
6
|
-
accessToken: string;
|
|
7
|
-
onTableClick?: (tableName: string) => void;
|
|
8
|
-
}
|
|
9
|
-
export default function TablesInSchema({ server, projectName, connectionName, schemaName, accessToken, onTableClick, }: TablesInSchemaProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
export interface PublisherPackageContextProps {
|
|
4
|
-
server?: string;
|
|
5
|
-
projectName: string;
|
|
6
|
-
packageName: string;
|
|
7
|
-
versionId?: string;
|
|
8
|
-
accessToken?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const PublisherPackageContext = createContext<
|
|
12
|
-
PublisherPackageContextProps | undefined
|
|
13
|
-
>(undefined);
|
|
14
|
-
|
|
15
|
-
interface PublisherPackageProviderProps extends PublisherPackageContextProps {
|
|
16
|
-
children: ReactNode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Provider for the Publisher Package context.
|
|
20
|
-
// This context is used to pass the package information to the components
|
|
21
|
-
// that need it.
|
|
22
|
-
// The package information is passed to the components via the usePublisherPackage hook.
|
|
23
|
-
export const PublisherPackageProvider = ({
|
|
24
|
-
server,
|
|
25
|
-
projectName,
|
|
26
|
-
packageName,
|
|
27
|
-
versionId,
|
|
28
|
-
accessToken,
|
|
29
|
-
children,
|
|
30
|
-
}: PublisherPackageProviderProps) => {
|
|
31
|
-
return (
|
|
32
|
-
<PublisherPackageContext.Provider
|
|
33
|
-
value={{ server, projectName, packageName, versionId, accessToken }}
|
|
34
|
-
>
|
|
35
|
-
{children}
|
|
36
|
-
</PublisherPackageContext.Provider>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export function usePublisherPackage() {
|
|
41
|
-
const context = useContext(PublisherPackageContext);
|
|
42
|
-
if (!context) {
|
|
43
|
-
throw new Error(
|
|
44
|
-
"usePublisherPackage must be used within a PublisherPackageProvider",
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
return context;
|
|
48
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
Box,
|
|
4
|
-
List,
|
|
5
|
-
ListItemButton,
|
|
6
|
-
ListItemText,
|
|
7
|
-
Typography,
|
|
8
|
-
Divider,
|
|
9
|
-
} from "@mui/material";
|
|
10
|
-
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
11
|
-
import { Configuration, ConnectionsApi } from "../../client";
|
|
12
|
-
|
|
13
|
-
const connectionsApi = new ConnectionsApi(new Configuration());
|
|
14
|
-
const queryClient = new QueryClient();
|
|
15
|
-
|
|
16
|
-
interface TablesInSchemaProps {
|
|
17
|
-
server?: string;
|
|
18
|
-
projectName: string;
|
|
19
|
-
connectionName: string;
|
|
20
|
-
schemaName: string;
|
|
21
|
-
accessToken: string;
|
|
22
|
-
onTableClick?: (tableName: string) => void;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default function TablesInSchema({
|
|
26
|
-
server,
|
|
27
|
-
projectName,
|
|
28
|
-
connectionName,
|
|
29
|
-
schemaName,
|
|
30
|
-
accessToken,
|
|
31
|
-
onTableClick,
|
|
32
|
-
}: TablesInSchemaProps) {
|
|
33
|
-
const { data, isSuccess, isError, error, isLoading } = useQuery(
|
|
34
|
-
{
|
|
35
|
-
queryKey: ["tables", server, projectName, connectionName, schemaName],
|
|
36
|
-
queryFn: () =>
|
|
37
|
-
connectionsApi.listTables(projectName, connectionName, schemaName, {
|
|
38
|
-
baseURL: server,
|
|
39
|
-
withCredentials: !accessToken,
|
|
40
|
-
headers: {
|
|
41
|
-
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
retry: false,
|
|
45
|
-
},
|
|
46
|
-
queryClient,
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Box sx={{ width: "100%" }}>
|
|
51
|
-
<Typography variant="overline" fontWeight="bold">
|
|
52
|
-
Tables in {schemaName}
|
|
53
|
-
</Typography>
|
|
54
|
-
<Divider />
|
|
55
|
-
<Box sx={{ mt: "10px", maxHeight: "200px", overflowY: "auto" }}>
|
|
56
|
-
{isLoading && (
|
|
57
|
-
<Typography variant="body2" sx={{ p: "20px", m: "auto" }}>
|
|
58
|
-
Fetching Tables...
|
|
59
|
-
</Typography>
|
|
60
|
-
)}
|
|
61
|
-
{isError && (
|
|
62
|
-
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
63
|
-
{`${projectName} > ${connectionName} > ${schemaName} - ${error.message}`}
|
|
64
|
-
</Typography>
|
|
65
|
-
)}
|
|
66
|
-
{isSuccess && data.data.length === 0 && (
|
|
67
|
-
<Typography variant="body2">No Tables</Typography>
|
|
68
|
-
)}
|
|
69
|
-
{isSuccess && data.data.length > 0 && (
|
|
70
|
-
<List dense disablePadding>
|
|
71
|
-
{data.data.map((table: string) => (
|
|
72
|
-
<ListItemButton
|
|
73
|
-
key={table}
|
|
74
|
-
onClick={() => onTableClick && onTableClick(table)}
|
|
75
|
-
>
|
|
76
|
-
<ListItemText primary={table} />
|
|
77
|
-
</ListItemButton>
|
|
78
|
-
))}
|
|
79
|
-
</List>
|
|
80
|
-
)}
|
|
81
|
-
</Box>
|
|
82
|
-
</Box>
|
|
83
|
-
);
|
|
84
|
-
}
|