@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
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-nKbldp0y.cjs");exports.BrowserNotebookStorage=e.BrowserNotebookStorage;exports.ConnectionExplorer=e.ConnectionExplorer;exports.Home=e.Home;exports.Model=e.Model;exports.MutableNotebook=e.MutableNotebook;exports.Notebook=e.Notebook;exports.NotebookStorageProvider=e.NotebookStorageProvider;exports.Package=e.Package;exports.PackageProvider=e.PackageProvider;exports.Project=e.Project;exports.ProjectProvider=e.ProjectProvider;exports.PublisherPackageProvider=e.PackageProvider;exports.QueryResult=e.QueryResult;exports.SourceExplorerComponent=e.SourceExplorerComponent;exports.SourcesExplorer=e.SourcesExplorer;exports.useNotebookStorage=e.useNotebookStorage;exports.usePackage=e.usePackage;exports.useProject=e.useProject;exports.usePublisherPackage=e.usePackage;exports.useRouterClickHandler=e.useRouterClickHandler;
|
package/dist/index.es.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import { B as a, C as r, H as s, M as t, b as
|
|
1
|
+
import { B as a, C as r, H as s, M as t, b as P, N as u, c, P as k, e as l, g as b, h as g, e as i, Q as d, a as n, S as N, d as S, f as p, j, f as v, u as x } from "./index-DvGSfdDD.js";
|
|
2
2
|
export {
|
|
3
3
|
a as BrowserNotebookStorage,
|
|
4
4
|
r as ConnectionExplorer,
|
|
5
5
|
s as Home,
|
|
6
6
|
t as Model,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
g as
|
|
14
|
-
i as
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
P as MutableNotebook,
|
|
8
|
+
u as Notebook,
|
|
9
|
+
c as NotebookStorageProvider,
|
|
10
|
+
k as Package,
|
|
11
|
+
l as PackageProvider,
|
|
12
|
+
b as Project,
|
|
13
|
+
g as ProjectProvider,
|
|
14
|
+
i as PublisherPackageProvider,
|
|
15
|
+
d as QueryResult,
|
|
16
|
+
n as SourceExplorerComponent,
|
|
17
|
+
N as SourcesExplorer,
|
|
18
|
+
S as useNotebookStorage,
|
|
19
|
+
p as usePackage,
|
|
20
|
+
j as useProject,
|
|
21
|
+
v as usePublisherPackage,
|
|
22
|
+
x as useRouterClickHandler
|
|
19
23
|
};
|
|
@@ -75249,11 +75249,11 @@ export {
|
|
|
75249
75249
|
bM as C,
|
|
75250
75250
|
Vh as D,
|
|
75251
75251
|
ire as E,
|
|
75252
|
-
|
|
75253
|
-
|
|
75254
|
-
|
|
75252
|
+
oF as F,
|
|
75253
|
+
CF as G,
|
|
75254
|
+
gF as H,
|
|
75255
75255
|
A6 as I,
|
|
75256
|
-
|
|
75256
|
+
r5 as J,
|
|
75257
75257
|
cre as K,
|
|
75258
75258
|
One as L,
|
|
75259
75259
|
ore as M,
|
|
@@ -75314,5 +75314,5 @@ export {
|
|
|
75314
75314
|
Y4 as w,
|
|
75315
75315
|
h5 as x,
|
|
75316
75316
|
J4 as y,
|
|
75317
|
-
|
|
75317
|
+
l5 as z
|
|
75318
75318
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Typography } from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
export interface ApiError extends Error {
|
|
5
|
+
status?: number;
|
|
6
|
+
data?: {
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ApiErrorDisplayProps {
|
|
13
|
+
error: ApiError;
|
|
14
|
+
context?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function ApiErrorDisplay({ error, context }: ApiErrorDisplayProps) {
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
{context && (
|
|
21
|
+
<Typography variant="body2" sx={{ p: "10px", m: "auto" }}>
|
|
22
|
+
{context}
|
|
23
|
+
</Typography>
|
|
24
|
+
)}
|
|
25
|
+
{error.data && (
|
|
26
|
+
<pre
|
|
27
|
+
style={{
|
|
28
|
+
whiteSpace: "pre-wrap",
|
|
29
|
+
color: "red",
|
|
30
|
+
backgroundColor: "black",
|
|
31
|
+
padding: "10px",
|
|
32
|
+
margin: "auto",
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{error.data.message}
|
|
36
|
+
</pre>
|
|
37
|
+
)}
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -2,6 +2,7 @@ import { Grid, Typography } from "@mui/material";
|
|
|
2
2
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { ProjectsApi, Configuration } from "../../client";
|
|
4
4
|
import axios from "axios";
|
|
5
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
5
6
|
|
|
6
7
|
axios.defaults.baseURL = "http://localhost:4000";
|
|
7
8
|
const projectsApi = new ProjectsApi(new Configuration());
|
|
@@ -13,19 +14,25 @@ interface HomeProps {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export default function Home({ server, navigate }: HomeProps) {
|
|
16
|
-
const { data, isSuccess } = useQuery(
|
|
17
|
+
const { data, isSuccess, isError, error } = useQuery(
|
|
17
18
|
{
|
|
18
19
|
queryKey: ["projects", server],
|
|
19
20
|
queryFn: () =>
|
|
20
21
|
projectsApi.listProjects({
|
|
21
22
|
baseURL: server,
|
|
22
23
|
}),
|
|
24
|
+
retry: false,
|
|
25
|
+
throwOnError: false,
|
|
23
26
|
},
|
|
24
27
|
queryClient,
|
|
25
28
|
);
|
|
26
29
|
|
|
27
30
|
console.log(JSON.stringify(data?.data, null, 2));
|
|
28
31
|
|
|
32
|
+
if (isError) {
|
|
33
|
+
return <ApiErrorDisplay error={error} context="Projects List" />;
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
if (isSuccess) {
|
|
30
37
|
if (data.data.length === 0) {
|
|
31
38
|
return <Typography variant="h4">No projects found</Typography>;
|
|
@@ -14,15 +14,17 @@ import {
|
|
|
14
14
|
} from "@mui/material";
|
|
15
15
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
16
16
|
import React, { useEffect } from "react";
|
|
17
|
-
import { Configuration, ModelsApi } from "../../client";
|
|
17
|
+
import { Configuration, ModelsApi, CompiledModel } from "../../client";
|
|
18
18
|
import { highlight } from "../highlighter";
|
|
19
19
|
import { StyledCard, StyledCardContent, StyledCardMedia } from "../styles";
|
|
20
20
|
import { ModelCell } from "./ModelCell";
|
|
21
|
+
import { ApiErrorDisplay, ApiError } from "../ApiErrorDisplay";
|
|
21
22
|
|
|
22
23
|
import "@malloydata/malloy-explorer/styles.css";
|
|
23
|
-
import {
|
|
24
|
+
import { usePackage } from "../Package/PackageProvider";
|
|
24
25
|
import { SourceExplorerComponent } from "./SourcesExplorer";
|
|
25
26
|
import NamedQueries from "./NamedQueries";
|
|
27
|
+
|
|
26
28
|
const modelsApi = new ModelsApi(new Configuration());
|
|
27
29
|
|
|
28
30
|
const queryClient = new QueryClient();
|
|
@@ -54,7 +56,7 @@ export default function Model({
|
|
|
54
56
|
const [selectedTab, setSelectedTab] = React.useState(0);
|
|
55
57
|
|
|
56
58
|
const { server, projectName, packageName, versionId, accessToken } =
|
|
57
|
-
|
|
59
|
+
usePackage();
|
|
58
60
|
const modelCodeSnippet = getModelCodeSnippet(server, packageName, modelPath);
|
|
59
61
|
useEffect(() => {
|
|
60
62
|
highlight(modelCodeSnippet, "typescript").then((code) => {
|
|
@@ -62,7 +64,10 @@ export default function Model({
|
|
|
62
64
|
});
|
|
63
65
|
}, [embeddingExpanded, modelCodeSnippet]);
|
|
64
66
|
|
|
65
|
-
const { data, isError, isLoading, error } = useQuery
|
|
67
|
+
const { data, isError, isLoading, error } = useQuery<
|
|
68
|
+
CompiledModel,
|
|
69
|
+
ApiError
|
|
70
|
+
>(
|
|
66
71
|
{
|
|
67
72
|
queryKey: [
|
|
68
73
|
"package",
|
|
@@ -72,17 +77,46 @@ export default function Model({
|
|
|
72
77
|
modelPath,
|
|
73
78
|
versionId,
|
|
74
79
|
],
|
|
75
|
-
queryFn: () =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
queryFn: async () => {
|
|
81
|
+
try {
|
|
82
|
+
const response = await modelsApi.getModel(
|
|
83
|
+
projectName,
|
|
84
|
+
packageName,
|
|
85
|
+
modelPath,
|
|
86
|
+
versionId,
|
|
87
|
+
{
|
|
88
|
+
baseURL: server,
|
|
89
|
+
withCredentials: !accessToken,
|
|
90
|
+
headers: {
|
|
91
|
+
Authorization: accessToken && `Bearer ${accessToken}`,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
return response.data;
|
|
96
|
+
} catch (err) {
|
|
97
|
+
// If it's an Axios error, it will have response data
|
|
98
|
+
if (err && typeof err === "object" && "response" in err) {
|
|
99
|
+
console.log("axios err", err);
|
|
100
|
+
const axiosError = err as any;
|
|
101
|
+
if (axiosError.response?.data) {
|
|
102
|
+
const apiError: ApiError = new Error(
|
|
103
|
+
axiosError.response.data.message || axiosError.message,
|
|
104
|
+
);
|
|
105
|
+
apiError.status = axiosError.response.status;
|
|
106
|
+
apiError.data = axiosError.response.data;
|
|
107
|
+
throw apiError;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// For other errors, throw as is
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
retry: false,
|
|
115
|
+
throwOnError: false,
|
|
83
116
|
},
|
|
84
117
|
queryClient,
|
|
85
118
|
);
|
|
119
|
+
|
|
86
120
|
if (isLoading) {
|
|
87
121
|
return (
|
|
88
122
|
<Typography sx={{ p: "20px", m: "auto" }}>
|
|
@@ -92,10 +126,12 @@ export default function Model({
|
|
|
92
126
|
}
|
|
93
127
|
|
|
94
128
|
if (isError) {
|
|
129
|
+
console.log("error", error);
|
|
95
130
|
return (
|
|
96
|
-
<
|
|
97
|
-
{
|
|
98
|
-
|
|
131
|
+
<ApiErrorDisplay
|
|
132
|
+
error={error}
|
|
133
|
+
context={`${packageName} > ${modelPath}`}
|
|
134
|
+
/>
|
|
99
135
|
);
|
|
100
136
|
}
|
|
101
137
|
return (
|
|
@@ -107,8 +143,8 @@ export default function Model({
|
|
|
107
143
|
justifyContent: "space-between",
|
|
108
144
|
}}
|
|
109
145
|
>
|
|
110
|
-
{Array.isArray(data.
|
|
111
|
-
data.
|
|
146
|
+
{Array.isArray(data.sourceInfos) &&
|
|
147
|
+
data.sourceInfos.length > 0 && (
|
|
112
148
|
<Tabs
|
|
113
149
|
value={selectedTab}
|
|
114
150
|
onChange={(_, newValue) => setSelectedTab(newValue)}
|
|
@@ -120,7 +156,7 @@ export default function Model({
|
|
|
120
156
|
minHeight: 36,
|
|
121
157
|
}}
|
|
122
158
|
>
|
|
123
|
-
{data.
|
|
159
|
+
{data.sourceInfos.map((source, idx) => {
|
|
124
160
|
let sourceInfo;
|
|
125
161
|
try {
|
|
126
162
|
sourceInfo = JSON.parse(source);
|
|
@@ -203,18 +239,18 @@ export default function Model({
|
|
|
203
239
|
<StyledCardMedia>
|
|
204
240
|
<Stack spacing={2} component="section">
|
|
205
241
|
{/* Only render the selected sourceInfo */}
|
|
206
|
-
{Array.isArray(data.
|
|
207
|
-
data.
|
|
242
|
+
{Array.isArray(data.sourceInfos) &&
|
|
243
|
+
data.sourceInfos.length > 0 && (
|
|
208
244
|
<SourceExplorerComponent
|
|
209
245
|
sourceAndPath={{
|
|
210
246
|
modelPath,
|
|
211
247
|
sourceInfo: JSON.parse(
|
|
212
|
-
data.
|
|
248
|
+
data.sourceInfos[selectedTab],
|
|
213
249
|
),
|
|
214
250
|
}}
|
|
215
251
|
/>
|
|
216
252
|
)}
|
|
217
|
-
{data.
|
|
253
|
+
{data.queries?.length > 0 && (
|
|
218
254
|
<StyledCard
|
|
219
255
|
variant="outlined"
|
|
220
256
|
sx={{ padding: "0px 10px 0px 10px" }}
|
|
@@ -225,20 +261,15 @@ export default function Model({
|
|
|
225
261
|
</Typography>
|
|
226
262
|
</StyledCardContent>
|
|
227
263
|
<Stack spacing={1} component="section">
|
|
228
|
-
{data.
|
|
264
|
+
{data.queries.map((query) => (
|
|
229
265
|
<ModelCell
|
|
230
266
|
key={query.name}
|
|
231
|
-
server={server}
|
|
232
|
-
projectName={projectName}
|
|
233
|
-
packageName={packageName}
|
|
234
267
|
modelPath={modelPath}
|
|
235
|
-
versionId={versionId}
|
|
236
268
|
queryName={query.name}
|
|
237
269
|
expandResult={expandResults}
|
|
238
270
|
hideResultIcon={hideResultIcons}
|
|
239
271
|
expandEmbedding={expandEmbeddings}
|
|
240
272
|
hideEmbeddingIcon={hideEmbeddingIcons}
|
|
241
|
-
accessToken={accessToken}
|
|
242
273
|
noView={true}
|
|
243
274
|
annotations={query.annotations}
|
|
244
275
|
/>
|
|
@@ -17,6 +17,7 @@ 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";
|
|
20
21
|
|
|
21
22
|
const StyledCard = styled(Card)({
|
|
22
23
|
display: "flex",
|
|
@@ -25,75 +26,60 @@ const StyledCard = styled(Card)({
|
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
interface ModelCellProps {
|
|
28
|
-
server: string;
|
|
29
|
-
projectName: string;
|
|
30
|
-
packageName: string;
|
|
31
29
|
modelPath: string;
|
|
32
|
-
versionId: string;
|
|
33
30
|
sourceName?: string;
|
|
34
31
|
queryName: string;
|
|
35
32
|
expandResult?: boolean;
|
|
36
33
|
hideResultIcon?: boolean;
|
|
37
34
|
expandEmbedding?: boolean;
|
|
38
35
|
hideEmbeddingIcon?: boolean;
|
|
39
|
-
accessToken?: string;
|
|
40
36
|
noView?: boolean;
|
|
41
37
|
annotations?: string[];
|
|
42
38
|
}
|
|
43
39
|
|
|
44
40
|
export function ModelCell({
|
|
45
|
-
server,
|
|
46
|
-
projectName,
|
|
47
|
-
packageName,
|
|
48
41
|
modelPath,
|
|
49
|
-
versionId,
|
|
50
42
|
sourceName,
|
|
51
43
|
queryName,
|
|
52
44
|
expandResult,
|
|
53
45
|
hideResultIcon,
|
|
54
46
|
expandEmbedding,
|
|
55
47
|
hideEmbeddingIcon,
|
|
56
|
-
accessToken,
|
|
57
48
|
noView,
|
|
58
49
|
annotations,
|
|
59
50
|
}: ModelCellProps) {
|
|
60
51
|
const [resultsExpanded, setResultsExpanded] = React.useState(expandResult);
|
|
61
52
|
const [embeddingExpanded, setEmbeddingExpanded] =
|
|
62
|
-
React.useState(expandEmbedding);
|
|
53
|
+
React.useState<boolean>(expandEmbedding);
|
|
63
54
|
const [highlightedEmbedCode, setHighlightedEmbedCode] =
|
|
64
55
|
React.useState<string>();
|
|
65
56
|
const [highlightedAnnotations, setHighlightedAnnotations] =
|
|
66
57
|
React.useState<string>();
|
|
67
58
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
server,
|
|
72
|
-
projectName,
|
|
73
|
-
packageName,
|
|
74
|
-
modelPath,
|
|
75
|
-
versionId,
|
|
76
|
-
sourceName,
|
|
77
|
-
queryName,
|
|
78
|
-
),
|
|
79
|
-
"typescript",
|
|
80
|
-
).then((code) => {
|
|
81
|
-
setHighlightedEmbedCode(code);
|
|
82
|
-
});
|
|
83
|
-
}, [
|
|
59
|
+
const { server, projectName, packageName, versionId } = usePackage();
|
|
60
|
+
|
|
61
|
+
const queryResultCodeSnippet = getQueryResultCodeSnippet(
|
|
84
62
|
server,
|
|
85
63
|
projectName,
|
|
86
64
|
packageName,
|
|
87
|
-
modelPath,
|
|
88
65
|
versionId,
|
|
89
66
|
sourceName,
|
|
90
67
|
queryName,
|
|
91
|
-
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
highlight(queryResultCodeSnippet, "typescript").then((code) => {
|
|
72
|
+
setHighlightedEmbedCode(code);
|
|
73
|
+
});
|
|
74
|
+
}, [embeddingExpanded, queryResultCodeSnippet]);
|
|
92
75
|
|
|
93
76
|
useEffect(() => {
|
|
94
|
-
if (annotations) {
|
|
95
|
-
|
|
96
|
-
|
|
77
|
+
if (annotations && annotations.length > 0) {
|
|
78
|
+
const code = annotations
|
|
79
|
+
.map((annotation) => `// ${annotation}`)
|
|
80
|
+
.join("\n");
|
|
81
|
+
highlight(code, "typescript").then((highlightedCode) => {
|
|
82
|
+
setHighlightedAnnotations(highlightedCode);
|
|
97
83
|
});
|
|
98
84
|
}
|
|
99
85
|
}, [annotations]);
|
|
@@ -155,39 +141,33 @@ export function ModelCell({
|
|
|
155
141
|
</CardActions>
|
|
156
142
|
</Stack>
|
|
157
143
|
<Collapse in={embeddingExpanded} timeout="auto" unmountOnExit>
|
|
158
|
-
<Divider
|
|
144
|
+
<Divider />
|
|
159
145
|
<Stack
|
|
160
146
|
sx={{
|
|
147
|
+
p: "10px",
|
|
161
148
|
borderRadius: 0,
|
|
162
149
|
flexDirection: "row",
|
|
163
150
|
justifyContent: "space-between",
|
|
164
151
|
}}
|
|
165
152
|
>
|
|
166
153
|
<Typography
|
|
167
|
-
|
|
168
|
-
|
|
154
|
+
sx={{
|
|
155
|
+
fontSize: "12px",
|
|
156
|
+
"& .line": { textWrap: "wrap" },
|
|
157
|
+
}}
|
|
169
158
|
>
|
|
170
159
|
<div
|
|
171
|
-
className="content"
|
|
172
160
|
dangerouslySetInnerHTML={{
|
|
173
161
|
__html: highlightedEmbedCode,
|
|
174
162
|
}}
|
|
175
163
|
/>
|
|
176
164
|
</Typography>
|
|
177
|
-
<Tooltip title="
|
|
165
|
+
<Tooltip title="Copy Embeddable Code">
|
|
178
166
|
<IconButton
|
|
179
167
|
sx={{ width: "24px", height: "24px" }}
|
|
180
168
|
onClick={() => {
|
|
181
169
|
navigator.clipboard.writeText(
|
|
182
|
-
|
|
183
|
-
server,
|
|
184
|
-
projectName,
|
|
185
|
-
packageName,
|
|
186
|
-
modelPath,
|
|
187
|
-
versionId,
|
|
188
|
-
sourceName,
|
|
189
|
-
queryName,
|
|
190
|
-
),
|
|
170
|
+
queryResultCodeSnippet,
|
|
191
171
|
);
|
|
192
172
|
}}
|
|
193
173
|
>
|
|
@@ -227,14 +207,9 @@ export function ModelCell({
|
|
|
227
207
|
)}
|
|
228
208
|
<CardContent>
|
|
229
209
|
<QueryResult
|
|
230
|
-
server={server}
|
|
231
|
-
projectName={projectName}
|
|
232
|
-
packageName={packageName}
|
|
233
210
|
modelPath={modelPath}
|
|
234
|
-
versionId={versionId}
|
|
235
211
|
sourceName={sourceName}
|
|
236
212
|
queryName={queryName}
|
|
237
|
-
accessToken={accessToken}
|
|
238
213
|
/>
|
|
239
214
|
</CardContent>
|
|
240
215
|
</Collapse>
|
|
@@ -247,7 +222,6 @@ function getQueryResultCodeSnippet(
|
|
|
247
222
|
server: string,
|
|
248
223
|
projectName: string,
|
|
249
224
|
packageName: string,
|
|
250
|
-
modelPath: string,
|
|
251
225
|
versionId: string,
|
|
252
226
|
sourceName: string,
|
|
253
227
|
queryName: string,
|
|
@@ -257,19 +231,8 @@ server="${server}"
|
|
|
257
231
|
accessToken={accessToken}
|
|
258
232
|
projectName="${projectName}"
|
|
259
233
|
packageName="${packageName}"
|
|
260
|
-
modelPath="${modelPath}"
|
|
261
234
|
versionId="${versionId}"
|
|
262
235
|
sourceName="${sourceName}"
|
|
263
236
|
queryName="${queryName}"
|
|
264
237
|
/>`;
|
|
265
238
|
}
|
|
266
|
-
|
|
267
|
-
function getAnnotations(annotations: string[]): string {
|
|
268
|
-
let res = "";
|
|
269
|
-
|
|
270
|
-
for (const an of annotations) {
|
|
271
|
-
res += an;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return res;
|
|
275
|
-
}
|
|
@@ -10,7 +10,7 @@ import { StyledCard, StyledCardContent } from "../styles";
|
|
|
10
10
|
|
|
11
11
|
import { QueryClient, useMutation } from "@tanstack/react-query";
|
|
12
12
|
import { Configuration } from "../../client";
|
|
13
|
-
import {
|
|
13
|
+
import { usePackage } from "../Package";
|
|
14
14
|
import React from "react";
|
|
15
15
|
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
16
16
|
|
|
@@ -27,7 +27,7 @@ export default function NamedQueries({
|
|
|
27
27
|
modelPath,
|
|
28
28
|
}: NamedQueryProps) {
|
|
29
29
|
const { server, projectName, packageName, versionId, accessToken } =
|
|
30
|
-
|
|
30
|
+
usePackage();
|
|
31
31
|
const [namedQueryResults, setNamedQueryResults] = React.useState<
|
|
32
32
|
Record<string, string>
|
|
33
33
|
>({});
|
|
@@ -21,7 +21,7 @@ import { styled } from "@mui/material/styles";
|
|
|
21
21
|
import { QueryClient, useMutation } from "@tanstack/react-query";
|
|
22
22
|
import React from "react";
|
|
23
23
|
import { Configuration, QueryresultsApi } from "../../client";
|
|
24
|
-
import {
|
|
24
|
+
import { usePackage } from "../Package/PackageProvider";
|
|
25
25
|
|
|
26
26
|
const queryResultsApi = new QueryresultsApi(new Configuration());
|
|
27
27
|
const queryClient = new QueryClient();
|
|
@@ -87,8 +87,8 @@ export function SourcesExplorer({
|
|
|
87
87
|
const [selectedTab, setSelectedTab] = React.useState(
|
|
88
88
|
existingSourceName
|
|
89
89
|
? sourceAndPaths.findIndex(
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
(entry) => entry.sourceInfo.name === existingSourceName,
|
|
91
|
+
)
|
|
92
92
|
: 0,
|
|
93
93
|
);
|
|
94
94
|
|
|
@@ -193,7 +193,7 @@ export function SourceExplorerComponent({
|
|
|
193
193
|
}
|
|
194
194
|
}, [onChange, query]);
|
|
195
195
|
const { server, projectName, packageName, versionId, accessToken } =
|
|
196
|
-
|
|
196
|
+
usePackage();
|
|
197
197
|
const mutation = useMutation(
|
|
198
198
|
{
|
|
199
199
|
mutationFn: () => {
|
|
@@ -272,7 +272,6 @@ export function SourceExplorerComponent({
|
|
|
272
272
|
onFocusedNestViewPathChange={setFocusedNestViewPath}
|
|
273
273
|
onDrill={(params) => {
|
|
274
274
|
console.info(params);
|
|
275
|
-
window.alert("Drill!");
|
|
276
275
|
}}
|
|
277
276
|
>
|
|
278
277
|
<div
|
|
@@ -324,16 +323,16 @@ export function SourceExplorerComponent({
|
|
|
324
323
|
submittedQuery={
|
|
325
324
|
query?.malloyQuery
|
|
326
325
|
? {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
326
|
+
executionState: mutation.isPending
|
|
327
|
+
? "running"
|
|
328
|
+
: "finished",
|
|
329
|
+
response: {
|
|
330
|
+
result: query.malloyResult,
|
|
331
|
+
},
|
|
332
|
+
query: query.malloyQuery,
|
|
333
|
+
queryResolutionStartMillis: Date.now(),
|
|
334
|
+
onCancel: mutation.reset,
|
|
335
|
+
}
|
|
337
336
|
: undefined
|
|
338
337
|
}
|
|
339
338
|
options={{ showRawQuery: true }}
|
|
@@ -18,8 +18,9 @@ import {
|
|
|
18
18
|
import { QueryClient, useQuery } from "@tanstack/react-query";
|
|
19
19
|
import React from "react";
|
|
20
20
|
import { Configuration, ModelsApi } from "../../client";
|
|
21
|
-
import {
|
|
21
|
+
import { usePackage } from "../Package/PackageProvider";
|
|
22
22
|
import { StyledCard } from "../styles";
|
|
23
|
+
import { ApiErrorDisplay } from "../ApiErrorDisplay";
|
|
23
24
|
|
|
24
25
|
const modelsApi = new ModelsApi(new Configuration());
|
|
25
26
|
const queryClient = new QueryClient();
|
|
@@ -38,7 +39,7 @@ export function ModelPicker({
|
|
|
38
39
|
onModelChange,
|
|
39
40
|
}: ModelPickerProps) {
|
|
40
41
|
const { server, projectName, packageName, versionId, accessToken } =
|
|
41
|
-
|
|
42
|
+
usePackage();
|
|
42
43
|
const { data, isLoading, isSuccess, isError, error } = useQuery(
|
|
43
44
|
{
|
|
44
45
|
queryKey: ["models", server, projectName, packageName, versionId],
|
|
@@ -51,6 +52,7 @@ export function ModelPicker({
|
|
|
51
52
|
},
|
|
52
53
|
}),
|
|
53
54
|
retry: false,
|
|
55
|
+
throwOnError: false,
|
|
54
56
|
},
|
|
55
57
|
queryClient,
|
|
56
58
|
);
|
|
@@ -83,6 +85,15 @@ export function ModelPicker({
|
|
|
83
85
|
.map((model) => model.path);
|
|
84
86
|
}
|
|
85
87
|
|
|
88
|
+
if (isError) {
|
|
89
|
+
return (
|
|
90
|
+
<ApiErrorDisplay
|
|
91
|
+
error={error}
|
|
92
|
+
context={`${projectName} > ${packageName} > Model Picker`}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
86
97
|
return (
|
|
87
98
|
<StyledCard
|
|
88
99
|
sx={{ maxWidth: 400, marginLeft: "10px", padding: "10px 5px 5px 5px" }}
|
|
@@ -90,7 +101,6 @@ export function ModelPicker({
|
|
|
90
101
|
<Typography variant="h6">Imported Models</Typography>
|
|
91
102
|
<FormControl fullWidth>
|
|
92
103
|
{isLoading && <Typography>Loading...</Typography>}
|
|
93
|
-
{isError && <Typography>Error: {error.message}</Typography>}
|
|
94
104
|
<Stack
|
|
95
105
|
direction="row"
|
|
96
106
|
spacing={1}
|