@malloy-publisher/sdk 0.0.128 → 0.0.130
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 +12 -0
- package/dist/components/Model/Model.d.ts +2 -1
- package/dist/components/Model/ModelCell.d.ts +2 -1
- package/dist/components/Notebook/Notebook.d.ts +2 -1
- package/dist/components/Notebook/NotebookCell.d.ts +2 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +2 -1
- package/dist/index.cjs.js +66 -66
- package/dist/index.es.js +3451 -3398
- package/package.json +1 -1
- package/src/components/Connections/common.ts +10 -0
- package/src/components/Model/Model.tsx +3 -0
- package/src/components/Model/ModelCell.tsx +3 -0
- package/src/components/Notebook/Notebook.tsx +8 -3
- package/src/components/Notebook/NotebookCell.tsx +3 -0
- package/src/components/RenderedResult/ResultContainer.tsx +44 -2
package/package.json
CHANGED
|
@@ -130,6 +130,16 @@ export const connectionFieldsByType: Record<
|
|
|
130
130
|
name: "responseTimeoutMilliseconds",
|
|
131
131
|
type: "text",
|
|
132
132
|
},
|
|
133
|
+
{
|
|
134
|
+
label: "Private Key",
|
|
135
|
+
name: "privateKey",
|
|
136
|
+
type: "password",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
label: "Private Key Passphrase",
|
|
140
|
+
name: "privateKeyPass",
|
|
141
|
+
type: "password",
|
|
142
|
+
},
|
|
133
143
|
],
|
|
134
144
|
trino: [
|
|
135
145
|
{
|
|
@@ -23,6 +23,7 @@ interface ModelProps {
|
|
|
23
23
|
onChange?: (query: QueryExplorerResult) => void;
|
|
24
24
|
resourceUri: string;
|
|
25
25
|
runOnDemand?: boolean;
|
|
26
|
+
maxResultSize?: number;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
// Note: For this to properly render outside of publisher,
|
|
@@ -33,6 +34,7 @@ export default function Model({
|
|
|
33
34
|
onChange,
|
|
34
35
|
resourceUri,
|
|
35
36
|
runOnDemand = false,
|
|
37
|
+
maxResultSize = 0,
|
|
36
38
|
}: ModelProps) {
|
|
37
39
|
const { modelPath } = parseResourceUri(resourceUri);
|
|
38
40
|
const { data, isError, isLoading, error } = useModelData(resourceUri);
|
|
@@ -190,6 +192,7 @@ export default function Model({
|
|
|
190
192
|
annotations={query.annotations}
|
|
191
193
|
resourceUri={resourceUri}
|
|
192
194
|
runOnDemand={runOnDemand}
|
|
195
|
+
maxResultSize={maxResultSize}
|
|
193
196
|
/>
|
|
194
197
|
))}
|
|
195
198
|
</Stack>
|
|
@@ -17,6 +17,7 @@ interface ModelCellProps {
|
|
|
17
17
|
annotations?: string[];
|
|
18
18
|
resourceUri: string;
|
|
19
19
|
runOnDemand?: boolean;
|
|
20
|
+
maxResultSize?: number;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export function ModelCell({
|
|
@@ -24,6 +25,7 @@ export function ModelCell({
|
|
|
24
25
|
annotations,
|
|
25
26
|
resourceUri,
|
|
26
27
|
runOnDemand = false,
|
|
28
|
+
maxResultSize = 0,
|
|
27
29
|
}: ModelCellProps) {
|
|
28
30
|
const [highlightedAnnotations, setHighlightedAnnotations] =
|
|
29
31
|
React.useState<string>();
|
|
@@ -176,6 +178,7 @@ export function ModelCell({
|
|
|
176
178
|
minHeight={300}
|
|
177
179
|
maxHeight={600}
|
|
178
180
|
hideToggle={false}
|
|
181
|
+
maxResultSize={maxResultSize}
|
|
179
182
|
/>
|
|
180
183
|
)}
|
|
181
184
|
</CleanMetricCard>
|
|
@@ -4,18 +4,22 @@ import { CompiledNotebook } from "../../client";
|
|
|
4
4
|
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
5
5
|
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
6
6
|
|
|
7
|
+
import { parseResourceUri } from "../../utils/formatting";
|
|
7
8
|
import { Loading } from "../Loading";
|
|
9
|
+
import { useServer } from "../ServerProvider";
|
|
8
10
|
import { CleanNotebookContainer, CleanNotebookSection } from "../styles";
|
|
9
11
|
import { NotebookCell } from "./NotebookCell";
|
|
10
|
-
import { parseResourceUri } from "../../utils/formatting";
|
|
11
|
-
import { useServer } from "../ServerProvider";
|
|
12
12
|
|
|
13
13
|
interface NotebookProps {
|
|
14
14
|
resourceUri: string;
|
|
15
|
+
maxResultSize?: number;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
// Requires PackageProvider
|
|
18
|
-
export default function Notebook({
|
|
19
|
+
export default function Notebook({
|
|
20
|
+
resourceUri,
|
|
21
|
+
maxResultSize = 0,
|
|
22
|
+
}: NotebookProps) {
|
|
19
23
|
const { apiClients } = useServer();
|
|
20
24
|
const {
|
|
21
25
|
projectName,
|
|
@@ -55,6 +59,7 @@ export default function Notebook({ resourceUri }: NotebookProps) {
|
|
|
55
59
|
key={index}
|
|
56
60
|
index={index}
|
|
57
61
|
resourceUri={resourceUri}
|
|
62
|
+
maxResultSize={maxResultSize}
|
|
58
63
|
/>
|
|
59
64
|
))}
|
|
60
65
|
{isError && error.status === 404 && (
|
|
@@ -32,6 +32,7 @@ interface NotebookCellProps {
|
|
|
32
32
|
hideEmbeddingIcon?: boolean;
|
|
33
33
|
resourceUri: string;
|
|
34
34
|
index: number;
|
|
35
|
+
maxResultSize?: number;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export function NotebookCell({
|
|
@@ -40,6 +41,7 @@ export function NotebookCell({
|
|
|
40
41
|
hideEmbeddingIcon,
|
|
41
42
|
resourceUri,
|
|
42
43
|
index,
|
|
44
|
+
maxResultSize,
|
|
43
45
|
}: NotebookCellProps) {
|
|
44
46
|
const [codeDialogOpen, setCodeDialogOpen] = React.useState<boolean>(false);
|
|
45
47
|
const [embeddingDialogOpen, setEmbeddingDialogOpen] =
|
|
@@ -420,6 +422,7 @@ export function NotebookCell({
|
|
|
420
422
|
result={cell.result}
|
|
421
423
|
minHeight={300}
|
|
422
424
|
maxHeight={1000}
|
|
425
|
+
maxResultSize={maxResultSize}
|
|
423
426
|
/>
|
|
424
427
|
</Box>
|
|
425
428
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ExpandLess, ExpandMore } from "@mui/icons-material";
|
|
2
|
-
import { Box, IconButton } from "@mui/material";
|
|
1
|
+
import { ExpandLess, ExpandMore, Warning } from "@mui/icons-material";
|
|
2
|
+
import { Box, Button, IconButton, Typography } from "@mui/material";
|
|
3
3
|
import {
|
|
4
4
|
lazy,
|
|
5
5
|
Suspense,
|
|
@@ -17,6 +17,10 @@ interface ResultContainerProps {
|
|
|
17
17
|
minHeight: number;
|
|
18
18
|
maxHeight: number;
|
|
19
19
|
hideToggle?: boolean;
|
|
20
|
+
// if Results are larger than this size, show a warning and a button to proceed
|
|
21
|
+
// this is to prevent performance issues with large results.
|
|
22
|
+
// the default is 0, which means no warning will be shown.
|
|
23
|
+
maxResultSize?: number;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
// ResultContainer is a component that renders a result, with a toggle button to expand/collapse the result.
|
|
@@ -28,6 +32,7 @@ export default function ResultContainer({
|
|
|
28
32
|
minHeight,
|
|
29
33
|
maxHeight,
|
|
30
34
|
hideToggle = false,
|
|
35
|
+
maxResultSize = 0,
|
|
31
36
|
}: ResultContainerProps) {
|
|
32
37
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
33
38
|
const [contentHeight, setContentHeight] = useState<number>(0);
|
|
@@ -36,6 +41,7 @@ export default function ResultContainer({
|
|
|
36
41
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
37
42
|
const [explicitHeight, setExplicitHeight] = useState<number>(undefined);
|
|
38
43
|
const [isFillElement, setIsFillElement] = useState(false);
|
|
44
|
+
const [userAcknowledged, setUserAcknowledged] = useState(false);
|
|
39
45
|
const handleToggle = useCallback(() => {
|
|
40
46
|
const wasExpanded = isExpanded;
|
|
41
47
|
setIsExpanded(!isExpanded);
|
|
@@ -85,6 +91,42 @@ export default function ResultContainer({
|
|
|
85
91
|
if (!result) {
|
|
86
92
|
return null;
|
|
87
93
|
}
|
|
94
|
+
|
|
95
|
+
// Check if result exceeds max size and user hasn't acknowledged yet
|
|
96
|
+
const exceedsMaxSize = maxResultSize > 0 && result.length > maxResultSize;
|
|
97
|
+
if (exceedsMaxSize && !userAcknowledged) {
|
|
98
|
+
return (
|
|
99
|
+
<Box
|
|
100
|
+
sx={{
|
|
101
|
+
minHeight: `${minHeight}px`,
|
|
102
|
+
display: "flex",
|
|
103
|
+
flexDirection: "column",
|
|
104
|
+
alignItems: "center",
|
|
105
|
+
justifyContent: "center",
|
|
106
|
+
gap: 2,
|
|
107
|
+
p: 4,
|
|
108
|
+
backgroundColor: "#fafafa",
|
|
109
|
+
border: "1px solid",
|
|
110
|
+
borderColor: "#e0e0e0",
|
|
111
|
+
borderRadius: 1,
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
<Warning sx={{ fontSize: 48, color: "#757575" }} />
|
|
115
|
+
<Typography variant="h6" color="text.secondary" align="center">
|
|
116
|
+
Processing large results may cause browser performance issues.
|
|
117
|
+
Proceed?
|
|
118
|
+
</Typography>
|
|
119
|
+
<Button
|
|
120
|
+
variant="contained"
|
|
121
|
+
color="primary"
|
|
122
|
+
onClick={() => setUserAcknowledged(true)}
|
|
123
|
+
>
|
|
124
|
+
Proceed
|
|
125
|
+
</Button>
|
|
126
|
+
</Box>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
88
130
|
const loading = <Loading text="Loading..." centered={true} size={32} />;
|
|
89
131
|
const renderedHeight = isFillElement
|
|
90
132
|
? isExpanded
|