@malloy-publisher/sdk 0.0.81 → 0.0.83
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 +7 -0
- package/dist/components/Model/Model.d.ts +1 -1
- package/dist/components/Model/ModelExplorer.d.ts +19 -0
- package/dist/components/Model/index.d.ts +3 -0
- package/dist/components/Model/useModelData.d.ts +8 -0
- package/dist/index.cjs.js +61 -61
- package/dist/index.es.js +6897 -6874
- package/dist/markdown-editor.css +342 -0
- package/dist/styles.css +3 -0
- package/package.json +8 -2
- package/src/components/Model/Model.tsx +17 -114
- package/src/components/Model/ModelExplorer.tsx +138 -0
- package/src/components/Model/SourcesExplorer.tsx +65 -79
- package/src/components/Model/index.ts +3 -0
- package/src/components/Model/useModelData.ts +38 -0
- package/src/components/styles.ts +0 -3
|
@@ -235,7 +235,7 @@ function SourceExplorerComponentInner({
|
|
|
235
235
|
|
|
236
236
|
const onQueryChange = React.useCallback(
|
|
237
237
|
(malloyQuery: Malloy.Query) => {
|
|
238
|
-
setQuery({ ...query, malloyQuery });
|
|
238
|
+
setQuery({ ...query, malloyQuery, malloyResult: undefined });
|
|
239
239
|
},
|
|
240
240
|
[query],
|
|
241
241
|
);
|
|
@@ -243,88 +243,75 @@ function SourceExplorerComponentInner({
|
|
|
243
243
|
if (oldSourceInfo !== sourceAndPath.sourceInfo.name) {
|
|
244
244
|
return <div>Loading...</div>;
|
|
245
245
|
}
|
|
246
|
-
|
|
247
246
|
return (
|
|
248
|
-
<
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
247
|
+
<StyledExplorerContent key={sourceAndPath.sourceInfo.name}>
|
|
248
|
+
<MalloyExplorerProvider
|
|
249
|
+
source={sourceAndPath.sourceInfo}
|
|
250
|
+
query={query?.malloyQuery}
|
|
251
|
+
onQueryChange={onQueryChange}
|
|
252
|
+
focusedNestViewPath={focusedNestViewPath}
|
|
253
|
+
onFocusedNestViewPathChange={setFocusedNestViewPath}
|
|
254
|
+
onDrill={(params) => {
|
|
255
|
+
console.info(params);
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
258
|
+
<div
|
|
259
|
+
style={{
|
|
260
|
+
display: "flex",
|
|
261
|
+
height: "100%",
|
|
262
|
+
overflowY: "auto",
|
|
258
263
|
}}
|
|
259
264
|
>
|
|
260
|
-
<
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
265
|
+
<ResizableCollapsiblePanel
|
|
266
|
+
isInitiallyExpanded={true}
|
|
267
|
+
initialWidth={180}
|
|
268
|
+
minWidth={180}
|
|
269
|
+
icon="database"
|
|
270
|
+
title={sourceAndPath.sourceInfo.name}
|
|
266
271
|
>
|
|
267
|
-
<
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
+
<SourcePanel
|
|
273
|
+
onRefresh={() => setQuery(emptyQueryExplorerResult())}
|
|
274
|
+
/>
|
|
275
|
+
</ResizableCollapsiblePanel>
|
|
276
|
+
<ResizableCollapsiblePanel
|
|
277
|
+
isInitiallyExpanded={true}
|
|
278
|
+
initialWidth={280}
|
|
279
|
+
minWidth={280}
|
|
280
|
+
icon="filterSliders"
|
|
281
|
+
title="Query"
|
|
282
|
+
>
|
|
283
|
+
<QueryPanel
|
|
284
|
+
runQuery={() => {
|
|
285
|
+
mutation.mutate();
|
|
272
286
|
}}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
source={sourceAndPath.sourceInfo}
|
|
302
|
-
draftQuery={query?.malloyQuery}
|
|
303
|
-
setDraftQuery={(malloyQuery) =>
|
|
304
|
-
setQuery({ ...query, malloyQuery: malloyQuery })
|
|
305
|
-
}
|
|
306
|
-
submittedQuery={
|
|
307
|
-
query?.malloyQuery
|
|
308
|
-
? {
|
|
309
|
-
executionState: mutation.isPending
|
|
310
|
-
? "running"
|
|
311
|
-
: "finished",
|
|
312
|
-
response: {
|
|
313
|
-
result: query.malloyResult,
|
|
314
|
-
},
|
|
315
|
-
query: query.malloyQuery,
|
|
316
|
-
queryResolutionStartMillis: Date.now(),
|
|
317
|
-
onCancel: mutation.reset,
|
|
318
|
-
}
|
|
319
|
-
: undefined
|
|
320
|
-
}
|
|
321
|
-
options={{ showRawQuery: true }}
|
|
322
|
-
/>
|
|
323
|
-
</div>
|
|
324
|
-
</div>
|
|
325
|
-
</MalloyExplorerProvider>
|
|
326
|
-
</StyledExplorerContent>
|
|
327
|
-
</StyledExplorerPage>
|
|
287
|
+
/>
|
|
288
|
+
</ResizableCollapsiblePanel>
|
|
289
|
+
<ResultPanel
|
|
290
|
+
source={sourceAndPath.sourceInfo}
|
|
291
|
+
draftQuery={query?.malloyQuery}
|
|
292
|
+
setDraftQuery={(malloyQuery) =>
|
|
293
|
+
setQuery({ ...query, malloyQuery: malloyQuery })
|
|
294
|
+
}
|
|
295
|
+
submittedQuery={
|
|
296
|
+
query?.malloyQuery
|
|
297
|
+
? {
|
|
298
|
+
executionState: mutation.isPending
|
|
299
|
+
? "running"
|
|
300
|
+
: "finished",
|
|
301
|
+
response: {
|
|
302
|
+
result: query.malloyResult,
|
|
303
|
+
},
|
|
304
|
+
query: query.malloyQuery,
|
|
305
|
+
queryResolutionStartMillis: Date.now(),
|
|
306
|
+
onCancel: mutation.reset,
|
|
307
|
+
}
|
|
308
|
+
: undefined
|
|
309
|
+
}
|
|
310
|
+
options={{ showRawQuery: true }}
|
|
311
|
+
/>
|
|
312
|
+
</div>
|
|
313
|
+
</MalloyExplorerProvider>
|
|
314
|
+
</StyledExplorerContent>
|
|
328
315
|
);
|
|
329
316
|
}
|
|
330
317
|
|
|
@@ -366,7 +353,6 @@ export function SourceExplorerComponent(props: SourceExplorerComponentProps) {
|
|
|
366
353
|
<StyledExplorerContent>
|
|
367
354
|
<div
|
|
368
355
|
style={{
|
|
369
|
-
display: "flex",
|
|
370
356
|
alignItems: "center",
|
|
371
357
|
justifyContent: "center",
|
|
372
358
|
height: "200px",
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { default as Model } from "./Model";
|
|
2
|
+
export { ModelExplorer } from "./ModelExplorer";
|
|
2
3
|
export { SourcesExplorer } from "./SourcesExplorer";
|
|
3
4
|
export { SourceExplorerComponent } from "./SourcesExplorer";
|
|
4
5
|
export type { SourceAndPath } from "./SourcesExplorer";
|
|
6
|
+
export { useModelData } from "./useModelData";
|
|
7
|
+
export type { ModelExplorerProps } from "./ModelExplorer";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Configuration, ModelsApi, CompiledModel } from "../../client";
|
|
2
|
+
import { usePackage } from "../Package/PackageProvider";
|
|
3
|
+
import { useQueryWithApiError } from "../../hooks/useQueryWithApiError";
|
|
4
|
+
|
|
5
|
+
const modelsApi = new ModelsApi(new Configuration());
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Custom hook for fetching model data. Combines usePackage context with
|
|
9
|
+
* useQueryWithApiError to fetch a compiled model.
|
|
10
|
+
*/
|
|
11
|
+
export function useModelData(modelPath: string, versionId?: string) {
|
|
12
|
+
const {
|
|
13
|
+
projectName,
|
|
14
|
+
packageName,
|
|
15
|
+
versionId: packageVersionId,
|
|
16
|
+
} = usePackage();
|
|
17
|
+
const effectiveVersionId = versionId || packageVersionId;
|
|
18
|
+
|
|
19
|
+
return useQueryWithApiError<CompiledModel>({
|
|
20
|
+
queryKey: [
|
|
21
|
+
"package",
|
|
22
|
+
projectName,
|
|
23
|
+
packageName,
|
|
24
|
+
modelPath,
|
|
25
|
+
effectiveVersionId,
|
|
26
|
+
],
|
|
27
|
+
queryFn: async (config) => {
|
|
28
|
+
const response = await modelsApi.getModel(
|
|
29
|
+
projectName,
|
|
30
|
+
packageName,
|
|
31
|
+
modelPath,
|
|
32
|
+
effectiveVersionId,
|
|
33
|
+
config,
|
|
34
|
+
);
|
|
35
|
+
return response.data;
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
package/src/components/styles.ts
CHANGED
|
@@ -18,8 +18,6 @@ export const StyledCardMedia = styled(CardMedia)({
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
export const StyledExplorerPage = styled("div")({
|
|
21
|
-
display: "flex",
|
|
22
|
-
flexDirection: "column",
|
|
23
21
|
height: "100%",
|
|
24
22
|
});
|
|
25
23
|
|
|
@@ -32,7 +30,6 @@ export const StyledExplorerBanner = styled("div")({
|
|
|
32
30
|
});
|
|
33
31
|
|
|
34
32
|
export const StyledExplorerContent = styled("div")({
|
|
35
|
-
display: "flex",
|
|
36
33
|
height: "75vh",
|
|
37
34
|
width: "100%",
|
|
38
35
|
overflowY: "auto",
|