@malloy-publisher/sdk 0.0.85 → 0.0.86
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/dist/client/api.d.ts +218 -0
- package/dist/components/Project/ConnectionExplorer.d.ts +2 -1
- package/dist/index.cjs.js +63 -63
- package/dist/index.es.js +6950 -6709
- package/package.json +1 -1
- package/src/components/Project/ConnectionExplorer.tsx +101 -125
- package/src/components/Project/Packages.tsx +1 -4
package/package.json
CHANGED
|
@@ -8,10 +8,6 @@ import {
|
|
|
8
8
|
Divider,
|
|
9
9
|
Paper,
|
|
10
10
|
Grid,
|
|
11
|
-
Dialog,
|
|
12
|
-
DialogContent,
|
|
13
|
-
DialogTitle,
|
|
14
|
-
IconButton,
|
|
15
11
|
Switch,
|
|
16
12
|
FormControlLabel,
|
|
17
13
|
Table,
|
|
@@ -32,10 +28,12 @@ const connectionsApi = new ConnectionsApi(new Configuration());
|
|
|
32
28
|
|
|
33
29
|
interface ConnectionExplorerProps {
|
|
34
30
|
connectionName: string;
|
|
31
|
+
schema?: string;
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
export default function ConnectionExplorer({
|
|
38
35
|
connectionName,
|
|
36
|
+
schema,
|
|
39
37
|
}: ConnectionExplorerProps) {
|
|
40
38
|
const { projectName } = useProject();
|
|
41
39
|
|
|
@@ -43,7 +41,7 @@ export default function ConnectionExplorer({
|
|
|
43
41
|
undefined,
|
|
44
42
|
);
|
|
45
43
|
const [selectedSchema, setSelectedSchema] = React.useState<string | null>(
|
|
46
|
-
null,
|
|
44
|
+
schema || null,
|
|
47
45
|
);
|
|
48
46
|
const [showHiddenSchemas, setShowHiddenSchemas] = React.useState(false);
|
|
49
47
|
const { data, isSuccess, isError, error, isLoading } = useQueryWithApiError({
|
|
@@ -53,78 +51,83 @@ export default function ConnectionExplorer({
|
|
|
53
51
|
});
|
|
54
52
|
|
|
55
53
|
return (
|
|
56
|
-
<Grid container spacing={
|
|
57
|
-
|
|
58
|
-
<
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
</Box>
|
|
82
|
-
<Divider />
|
|
83
|
-
<Box sx={{ mt: "10px", maxHeight: "600px", overflowY: "auto" }}>
|
|
84
|
-
{isLoading && <Loading text="Fetching Table Paths..." />}
|
|
85
|
-
{isError && (
|
|
86
|
-
<ApiErrorDisplay
|
|
87
|
-
error={error}
|
|
88
|
-
context={`${projectName} > ${connectionName}`}
|
|
54
|
+
<Grid container spacing={1}>
|
|
55
|
+
{!schema && (
|
|
56
|
+
<Grid size={{ xs: 12, md: 4 }}>
|
|
57
|
+
<Paper sx={{ p: 1, m: 0 }}>
|
|
58
|
+
<Box
|
|
59
|
+
sx={{
|
|
60
|
+
display: "flex",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
justifyContent: "space-between",
|
|
63
|
+
mb: 0,
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<Typography variant="overline" fontWeight="bold">
|
|
67
|
+
Table Paths
|
|
68
|
+
</Typography>
|
|
69
|
+
<FormControlLabel
|
|
70
|
+
control={
|
|
71
|
+
<Switch
|
|
72
|
+
checked={showHiddenSchemas}
|
|
73
|
+
onChange={(e) =>
|
|
74
|
+
setShowHiddenSchemas(e.target.checked)
|
|
75
|
+
}
|
|
76
|
+
/>
|
|
77
|
+
}
|
|
78
|
+
label="Hidden Schemas"
|
|
89
79
|
/>
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
80
|
+
</Box>
|
|
81
|
+
<Divider sx={{ mt: "2px" }} />
|
|
82
|
+
<Box
|
|
83
|
+
sx={{ mt: "2px", maxHeight: "600px", overflowY: "auto" }}
|
|
84
|
+
>
|
|
85
|
+
{isLoading && <Loading text="Fetching Table Paths..." />}
|
|
86
|
+
{isError && (
|
|
87
|
+
<ApiErrorDisplay
|
|
88
|
+
error={error}
|
|
89
|
+
context={`${projectName} > ${connectionName}`}
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
92
|
+
{isSuccess && data.data.length === 0 && (
|
|
93
|
+
<Typography variant="body2">No Schemas</Typography>
|
|
94
|
+
)}
|
|
95
|
+
{isSuccess && data.data.length > 0 && (
|
|
96
|
+
<List dense disablePadding>
|
|
97
|
+
{data.data
|
|
98
|
+
.filter(
|
|
99
|
+
({ isHidden }) =>
|
|
100
|
+
showHiddenSchemas || !isHidden,
|
|
101
|
+
)
|
|
102
|
+
.sort((a, b) => {
|
|
103
|
+
if (a.isDefault === b.isDefault) return 0;
|
|
104
|
+
return a.isDefault ? -1 : 1;
|
|
105
|
+
})
|
|
106
|
+
.map(
|
|
107
|
+
(schema: {
|
|
108
|
+
name: string;
|
|
109
|
+
isDefault: boolean;
|
|
110
|
+
}) => (
|
|
111
|
+
<ListItemButton
|
|
112
|
+
key={schema.name}
|
|
113
|
+
selected={selectedSchema === schema.name}
|
|
114
|
+
onClick={() =>
|
|
115
|
+
setSelectedSchema(schema.name)
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
<ListItemText primary={schema.name} />
|
|
119
|
+
</ListItemButton>
|
|
120
|
+
),
|
|
121
|
+
)}
|
|
122
|
+
</List>
|
|
123
|
+
)}
|
|
124
|
+
</Box>
|
|
125
|
+
</Paper>
|
|
126
|
+
</Grid>
|
|
127
|
+
)}
|
|
128
|
+
<Grid size={{ xs: 12, md: schema ? 6 : 4 }}>
|
|
126
129
|
{selectedSchema && (
|
|
127
|
-
<Paper sx={{ p:
|
|
130
|
+
<Paper sx={{ p: 1, m: 0 }}>
|
|
128
131
|
<TablesInSchema
|
|
129
132
|
connectionName={connectionName}
|
|
130
133
|
schemaName={selectedSchema}
|
|
@@ -135,31 +138,32 @@ export default function ConnectionExplorer({
|
|
|
135
138
|
</Paper>
|
|
136
139
|
)}
|
|
137
140
|
</Grid>
|
|
138
|
-
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
141
|
+
<Grid size={{ xs: 12, md: schema ? 6 : 4 }}>
|
|
142
|
+
{selectedTable && selectedSchema && (
|
|
143
|
+
<Paper sx={{ p: 1, m: 0 }}>
|
|
144
|
+
<TableSchemaViewer
|
|
145
|
+
connectionName={connectionName}
|
|
146
|
+
schemaName={selectedSchema}
|
|
147
|
+
tableName={selectedTable}
|
|
148
|
+
/>
|
|
149
|
+
</Paper>
|
|
150
|
+
)}
|
|
151
|
+
</Grid>
|
|
146
152
|
</Grid>
|
|
147
153
|
);
|
|
148
154
|
}
|
|
149
155
|
|
|
150
|
-
type
|
|
156
|
+
type TableSchemaViewerProps = {
|
|
151
157
|
connectionName: string;
|
|
152
158
|
schemaName: string;
|
|
153
159
|
tableName: string;
|
|
154
|
-
onClose: () => void;
|
|
155
160
|
};
|
|
156
161
|
|
|
157
|
-
function
|
|
162
|
+
function TableSchemaViewer({
|
|
158
163
|
connectionName,
|
|
159
164
|
schemaName,
|
|
160
165
|
tableName,
|
|
161
|
-
|
|
162
|
-
}: TableViewerProps) {
|
|
166
|
+
}: TableSchemaViewerProps) {
|
|
163
167
|
const { projectName } = useProject();
|
|
164
168
|
|
|
165
169
|
const { data, isSuccess, isError, error, isLoading } = useQueryWithApiError({
|
|
@@ -180,41 +184,13 @@ function TableViewer({
|
|
|
180
184
|
),
|
|
181
185
|
});
|
|
182
186
|
|
|
183
|
-
if (isSuccess && data) {
|
|
184
|
-
console.log(data);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
187
|
return (
|
|
188
|
-
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
component="span"
|
|
195
|
-
style={{ textTransform: "uppercase" }}
|
|
196
|
-
>
|
|
197
|
-
{schemaName}.{tableName}
|
|
198
|
-
</Typography>
|
|
199
|
-
<IconButton
|
|
200
|
-
aria-label="close"
|
|
201
|
-
onClick={onClose}
|
|
202
|
-
sx={{ position: "absolute", right: 8, top: 8 }}
|
|
203
|
-
>
|
|
204
|
-
<Box
|
|
205
|
-
sx={{
|
|
206
|
-
width: 24,
|
|
207
|
-
height: 24,
|
|
208
|
-
display: "flex",
|
|
209
|
-
alignItems: "center",
|
|
210
|
-
justifyContent: "center",
|
|
211
|
-
}}
|
|
212
|
-
>
|
|
213
|
-
X
|
|
214
|
-
</Box>
|
|
215
|
-
</IconButton>
|
|
216
|
-
</DialogTitle>
|
|
217
|
-
<DialogContent>
|
|
188
|
+
<>
|
|
189
|
+
<Typography variant="overline" fontWeight="bold">
|
|
190
|
+
Schema: {schemaName}.{tableName}
|
|
191
|
+
</Typography>
|
|
192
|
+
<Divider />
|
|
193
|
+
<Box sx={{ mt: "10px", maxHeight: "600px", overflowY: "auto" }}>
|
|
218
194
|
{isLoading && <Loading text="Fetching Table Details..." />}
|
|
219
195
|
{isError && (
|
|
220
196
|
<ApiErrorDisplay
|
|
@@ -247,8 +223,8 @@ function TableViewer({
|
|
|
247
223
|
</Table>
|
|
248
224
|
</TableContainer>
|
|
249
225
|
)}
|
|
250
|
-
</
|
|
251
|
-
|
|
226
|
+
</Box>
|
|
227
|
+
</>
|
|
252
228
|
);
|
|
253
229
|
}
|
|
254
230
|
|
|
@@ -282,7 +258,7 @@ function TablesInSchema({
|
|
|
282
258
|
Tables in {schemaName}
|
|
283
259
|
</Typography>
|
|
284
260
|
<Divider />
|
|
285
|
-
<Box sx={{ mt: "
|
|
261
|
+
<Box sx={{ mt: "2px", maxHeight: "600px", overflowY: "auto" }}>
|
|
286
262
|
{isLoading && <Loading text="Fetching Tables..." />}
|
|
287
263
|
{isError && (
|
|
288
264
|
<ApiErrorDisplay
|
|
@@ -34,9 +34,6 @@ export default function Packages({ navigate }: PackagesProps) {
|
|
|
34
34
|
return a.name.localeCompare(b.name);
|
|
35
35
|
})
|
|
36
36
|
.map((p) => {
|
|
37
|
-
const href = p.resource
|
|
38
|
-
.replace("/api/v0/projects", "")
|
|
39
|
-
.replace("/packages", "");
|
|
40
37
|
return (
|
|
41
38
|
<Grid
|
|
42
39
|
size={{ xs: 12, sm: 12, md: 12, lg: 4 }}
|
|
@@ -53,7 +50,7 @@ export default function Packages({ navigate }: PackagesProps) {
|
|
|
53
50
|
transform: "translateY(-2px)",
|
|
54
51
|
},
|
|
55
52
|
}}
|
|
56
|
-
onClick={(event) => navigate(
|
|
53
|
+
onClick={(event) => navigate(p.name, event)}
|
|
57
54
|
>
|
|
58
55
|
<StyledCardContent>
|
|
59
56
|
<Typography
|