@malloy-publisher/sdk 0.0.36 → 0.0.37
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/{RenderedResult-DphykkT6.cjs → RenderedResult-ChKXzRBq.cjs} +1 -1
- package/dist/{RenderedResult-BlNz8j4d.js → RenderedResult-DkEsDzXb.js} +2 -2
- package/dist/components/Model/SourcesExplorer.d.ts +2 -2
- package/dist/components/MutableNotebook/EditableMalloyCell.d.ts +3 -3
- package/dist/components/MutableNotebook/MutableCell.d.ts +3 -4
- package/dist/components/MutableNotebook/MutableNotebook.d.ts +2 -1
- package/dist/{index-nKbldp0y.cjs → index-7mmEVMId.cjs} +314 -314
- package/dist/{index-DvGSfdDD.js → index-DdtGkJIk.js} +25143 -25072
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/{vendor-C8UD-eyK.js → vendor-C6w9JpPA.js} +16199 -19097
- package/dist/{vendor-BH1c2Hhy.cjs → vendor-DAoHVNwq.cjs} +140 -241
- package/package.json +1 -1
- package/src/components/Model/NamedQueries.tsx +13 -13
- package/src/components/Model/SourcesExplorer.tsx +21 -41
- package/src/components/MutableNotebook/EditableMalloyCell.tsx +4 -22
- package/src/components/MutableNotebook/ModelPicker.tsx +31 -52
- package/src/components/MutableNotebook/MutableCell.tsx +229 -137
- package/src/components/MutableNotebook/MutableNotebook.tsx +102 -62
- package/src/components/Package/Package.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Typography,
|
|
3
2
|
Accordion,
|
|
4
|
-
AccordionSummary,
|
|
5
3
|
AccordionDetails,
|
|
4
|
+
AccordionSummary,
|
|
5
|
+
Typography,
|
|
6
6
|
} from "@mui/material";
|
|
7
7
|
import { Box } from "@mui/system";
|
|
8
8
|
import { Query, QueryresultsApi } from "../../client/api";
|
|
9
9
|
import { StyledCard, StyledCardContent } from "../styles";
|
|
10
10
|
|
|
11
11
|
import { QueryClient, useMutation } from "@tanstack/react-query";
|
|
12
|
+
import React from "react";
|
|
12
13
|
import { Configuration } from "../../client";
|
|
13
14
|
import { usePackage } from "../Package";
|
|
14
|
-
import React from "react";
|
|
15
15
|
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
16
16
|
|
|
17
17
|
const queryResultsApi = new QueryresultsApi(new Configuration());
|
|
@@ -70,17 +70,17 @@ export default function NamedQueries({
|
|
|
70
70
|
|
|
71
71
|
const handleAccordionChange =
|
|
72
72
|
(query: Query, queryKey: string) =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
(_event: React.SyntheticEvent, isExpanded: boolean) => {
|
|
74
|
+
setExpandedAccordions((prev) => ({
|
|
75
|
+
...prev,
|
|
76
|
+
[queryKey]: isExpanded,
|
|
77
|
+
}));
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
// Trigger mutation only if expanding and we haven't executed this query before
|
|
80
|
+
if (isExpanded && !namedQueryResults[query.name]) {
|
|
81
|
+
mutation.mutate({ query });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
84
|
|
|
85
85
|
if (!namedQueries) {
|
|
86
86
|
return <div> Loading Named Queries</div>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Malloy from "@malloydata/malloy-interfaces";
|
|
2
2
|
import * as QueryBuilder from "@malloydata/malloy-query-builder";
|
|
3
|
-
import { Button
|
|
3
|
+
import { Button } from "@mui/material";
|
|
4
4
|
import { Box, Stack } from "@mui/system";
|
|
5
5
|
import {
|
|
6
6
|
StyledCard,
|
|
@@ -64,11 +64,7 @@ export interface SourceExplorerProps {
|
|
|
64
64
|
sourceAndPaths: SourceAndPath[];
|
|
65
65
|
existingQuery?: QueryExplorerResult;
|
|
66
66
|
existingSourceName?: string;
|
|
67
|
-
|
|
68
|
-
modelPath: string,
|
|
69
|
-
sourceName: string,
|
|
70
|
-
query: QueryExplorerResult,
|
|
71
|
-
) => void;
|
|
67
|
+
onChange?: (query: QueryExplorerResult) => void;
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
/**
|
|
@@ -80,15 +76,15 @@ export interface SourceExplorerProps {
|
|
|
80
76
|
*/
|
|
81
77
|
export function SourcesExplorer({
|
|
82
78
|
sourceAndPaths,
|
|
83
|
-
saveResult,
|
|
84
79
|
existingQuery,
|
|
85
80
|
existingSourceName,
|
|
81
|
+
onChange,
|
|
86
82
|
}: SourceExplorerProps) {
|
|
87
83
|
const [selectedTab, setSelectedTab] = React.useState(
|
|
88
84
|
existingSourceName
|
|
89
85
|
? sourceAndPaths.findIndex(
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
(entry) => entry.sourceInfo.name === existingSourceName,
|
|
87
|
+
)
|
|
92
88
|
: 0,
|
|
93
89
|
);
|
|
94
90
|
|
|
@@ -119,27 +115,6 @@ export function SourcesExplorer({
|
|
|
119
115
|
))}
|
|
120
116
|
</MultiRowTabBar>
|
|
121
117
|
)}
|
|
122
|
-
{saveResult && (
|
|
123
|
-
<CardActions
|
|
124
|
-
sx={{
|
|
125
|
-
padding: "0px 10px 0px 10px",
|
|
126
|
-
mb: "auto",
|
|
127
|
-
mt: "auto",
|
|
128
|
-
}}
|
|
129
|
-
>
|
|
130
|
-
<Button
|
|
131
|
-
onClick={() =>
|
|
132
|
-
saveResult(
|
|
133
|
-
sourceAndPaths[selectedTab].modelPath,
|
|
134
|
-
sourceAndPaths[selectedTab].sourceInfo.name,
|
|
135
|
-
query,
|
|
136
|
-
)
|
|
137
|
-
}
|
|
138
|
-
>
|
|
139
|
-
Save
|
|
140
|
-
</Button>
|
|
141
|
-
</CardActions>
|
|
142
|
-
)}
|
|
143
118
|
</Stack>
|
|
144
119
|
</StyledCardContent>
|
|
145
120
|
<StyledCardMedia>
|
|
@@ -147,7 +122,12 @@ export function SourcesExplorer({
|
|
|
147
122
|
<SourceExplorerComponent
|
|
148
123
|
sourceAndPath={sourceAndPaths[selectedTab]}
|
|
149
124
|
existingQuery={query}
|
|
150
|
-
onChange={
|
|
125
|
+
onChange={(query) => {
|
|
126
|
+
setQuery(query);
|
|
127
|
+
if (onChange) {
|
|
128
|
+
onChange(query);
|
|
129
|
+
}
|
|
130
|
+
}}
|
|
151
131
|
/>
|
|
152
132
|
<Box height="5px" />
|
|
153
133
|
</Stack>
|
|
@@ -323,16 +303,16 @@ export function SourceExplorerComponent({
|
|
|
323
303
|
submittedQuery={
|
|
324
304
|
query?.malloyQuery
|
|
325
305
|
? {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
306
|
+
executionState: mutation.isPending
|
|
307
|
+
? "running"
|
|
308
|
+
: "finished",
|
|
309
|
+
response: {
|
|
310
|
+
result: query.malloyResult,
|
|
311
|
+
},
|
|
312
|
+
query: query.malloyQuery,
|
|
313
|
+
queryResolutionStartMillis: Date.now(),
|
|
314
|
+
onCancel: mutation.reset,
|
|
315
|
+
}
|
|
336
316
|
: undefined
|
|
337
317
|
}
|
|
338
318
|
options={{ showRawQuery: true }}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { SourceAndPath, SourcesExplorer } from "../Model";
|
|
2
|
+
import { QueryExplorerResult } from "../Model/SourcesExplorer";
|
|
2
3
|
import { NotebookCellValue } from "../NotebookManager";
|
|
3
4
|
|
|
4
5
|
interface EditableMalloyCellProps {
|
|
5
6
|
cell: NotebookCellValue;
|
|
6
7
|
sourceAndPaths: SourceAndPath[];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
onClose: () => void;
|
|
8
|
+
onChange: (query: QueryExplorerResult) => void;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export function EditableMalloyCell({
|
|
13
12
|
cell,
|
|
14
13
|
sourceAndPaths,
|
|
15
|
-
|
|
16
|
-
onClose,
|
|
14
|
+
onChange,
|
|
17
15
|
}: EditableMalloyCellProps) {
|
|
18
16
|
const query = {
|
|
19
17
|
query: cell.value,
|
|
@@ -25,23 +23,7 @@ export function EditableMalloyCell({
|
|
|
25
23
|
sourceAndPaths={sourceAndPaths}
|
|
26
24
|
existingQuery={query}
|
|
27
25
|
existingSourceName={cell.sourceName}
|
|
28
|
-
|
|
29
|
-
// Convert the results of the Query Explorer into
|
|
30
|
-
// the stringified JSON objects that are stored in the cell.
|
|
31
|
-
onCellChange({
|
|
32
|
-
...cell,
|
|
33
|
-
value: qer.query,
|
|
34
|
-
result: qer.malloyResult
|
|
35
|
-
? JSON.stringify(qer.malloyResult)
|
|
36
|
-
: undefined,
|
|
37
|
-
queryInfo: qer.malloyQuery
|
|
38
|
-
? JSON.stringify(qer.malloyQuery)
|
|
39
|
-
: undefined,
|
|
40
|
-
sourceName,
|
|
41
|
-
modelPath,
|
|
42
|
-
});
|
|
43
|
-
onClose();
|
|
44
|
-
}}
|
|
26
|
+
onChange={onChange}
|
|
45
27
|
/>
|
|
46
28
|
);
|
|
47
29
|
}
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import AddIcon from "@mui/icons-material/Add";
|
|
2
1
|
import CloseIcon from "@mui/icons-material/Close";
|
|
2
|
+
import FileUploadOutlinedIcon from "@mui/icons-material/FileUploadOutlined";
|
|
3
3
|
import {
|
|
4
4
|
Button,
|
|
5
5
|
Chip,
|
|
6
|
-
|
|
7
|
-
DialogActions,
|
|
8
|
-
DialogContent,
|
|
9
|
-
DialogTitle,
|
|
6
|
+
Divider,
|
|
10
7
|
FormControl,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ListItemButton,
|
|
14
|
-
ListItemText,
|
|
8
|
+
Menu,
|
|
9
|
+
MenuItem,
|
|
15
10
|
Stack,
|
|
16
11
|
Typography,
|
|
17
12
|
} from "@mui/material";
|
|
18
13
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
19
14
|
import React from "react";
|
|
20
15
|
import { Configuration, ModelsApi } from "../../client";
|
|
21
|
-
import { usePackage } from "../Package/PackageProvider";
|
|
22
|
-
import { StyledCard } from "../styles";
|
|
23
16
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
17
|
+
import { usePackage } from "../Package/PackageProvider";
|
|
24
18
|
|
|
25
19
|
const modelsApi = new ModelsApi(new Configuration());
|
|
26
20
|
const queryClient = new QueryClient();
|
|
@@ -59,7 +53,7 @@ export function ModelPicker({
|
|
|
59
53
|
const [selectedModels, setSelectedModels] = React.useState<string[]>(
|
|
60
54
|
initialSelectedModels || [],
|
|
61
55
|
);
|
|
62
|
-
const [
|
|
56
|
+
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
63
57
|
|
|
64
58
|
React.useEffect(() => {
|
|
65
59
|
setSelectedModels(initialSelectedModels || []);
|
|
@@ -75,7 +69,7 @@ export function ModelPicker({
|
|
|
75
69
|
const newModels = [...selectedModels, model];
|
|
76
70
|
setSelectedModels(newModels);
|
|
77
71
|
onModelChange(newModels);
|
|
78
|
-
|
|
72
|
+
setAnchorEl(null);
|
|
79
73
|
};
|
|
80
74
|
|
|
81
75
|
let availableModels: string[] = [];
|
|
@@ -95,22 +89,10 @@ export function ModelPicker({
|
|
|
95
89
|
}
|
|
96
90
|
|
|
97
91
|
return (
|
|
98
|
-
|
|
99
|
-
sx={{ maxWidth: 400, marginLeft: "10px", padding: "10px 5px 5px 5px" }}
|
|
100
|
-
>
|
|
101
|
-
<Typography variant="h6">Imported Models</Typography>
|
|
92
|
+
<>
|
|
102
93
|
<FormControl fullWidth>
|
|
103
94
|
{isLoading && <Typography>Loading...</Typography>}
|
|
104
|
-
<Stack
|
|
105
|
-
direction="row"
|
|
106
|
-
spacing={1}
|
|
107
|
-
sx={{
|
|
108
|
-
flexWrap: "wrap",
|
|
109
|
-
minHeight: 30,
|
|
110
|
-
alignItems: "center",
|
|
111
|
-
rowGap: "8px",
|
|
112
|
-
}}
|
|
113
|
-
>
|
|
95
|
+
<Stack direction="row" spacing={1}>
|
|
114
96
|
{selectedModels.map((model) => (
|
|
115
97
|
<Chip
|
|
116
98
|
key={model}
|
|
@@ -121,11 +103,9 @@ export function ModelPicker({
|
|
|
121
103
|
/>
|
|
122
104
|
))}
|
|
123
105
|
<Button
|
|
124
|
-
variant="outlined"
|
|
125
106
|
size="small"
|
|
126
|
-
startIcon={<
|
|
127
|
-
onClick={() =>
|
|
128
|
-
sx={{ height: 32, marginTop: "10px" }}
|
|
107
|
+
startIcon={<FileUploadOutlinedIcon />}
|
|
108
|
+
onClick={(e) => setAnchorEl(e.currentTarget)}
|
|
129
109
|
disabled={
|
|
130
110
|
isLoading || isError || availableModels.length === 0
|
|
131
111
|
}
|
|
@@ -134,26 +114,25 @@ export function ModelPicker({
|
|
|
134
114
|
</Button>
|
|
135
115
|
</Stack>
|
|
136
116
|
</FormControl>
|
|
137
|
-
<
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
))}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
</StyledCard>
|
|
117
|
+
<Menu
|
|
118
|
+
anchorEl={anchorEl}
|
|
119
|
+
open={Boolean(anchorEl)}
|
|
120
|
+
onClose={() => setAnchorEl(null)}
|
|
121
|
+
>
|
|
122
|
+
<Typography variant="subtitle2" sx={{ ml: 1 }}>
|
|
123
|
+
Models
|
|
124
|
+
</Typography>
|
|
125
|
+
<Divider />
|
|
126
|
+
{availableModels.length === 0 ? (
|
|
127
|
+
<MenuItem disabled>No models available</MenuItem>
|
|
128
|
+
) : (
|
|
129
|
+
availableModels.map((model) => (
|
|
130
|
+
<MenuItem key={model} onClick={() => handleAdd(model)}>
|
|
131
|
+
<Typography variant="body2">{model}</Typography>
|
|
132
|
+
</MenuItem>
|
|
133
|
+
))
|
|
134
|
+
)}
|
|
135
|
+
</Menu>
|
|
136
|
+
</>
|
|
158
137
|
);
|
|
159
138
|
}
|